diff --git a/CHANGELOG.md b/CHANGELOG.md index 4caae0e..e78e2a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## Unreleased + +### Fixed + +- Fix the dictionary build script incorrectly keeping redundant "character maps to itself" entries for characters outside the Basic Multilingual Plane (e.g. 𪙏), since `String.prototype.length` counts UTF-16 code units rather than code points. These entries are now correctly filtered out, slightly reducing dictionary size with no effect on conversion results. ([#49](https://github.com/nk2028/opencc-js/issues/49), reported by [@obxyann](https://github.com/obxyann), thanks!) + ## 1.4.2 - 2026-08-22 ### Changed diff --git a/build.js b/build.js index 0398b78..5be2963 100644 --- a/build.js +++ b/build.js @@ -126,7 +126,7 @@ function loadFile(fileName) { if (!fileContentCache[fileName]) { fileContentCache[fileName] = getEntries(fileName) .map(([k, values]) => [k, values[0]]) // only select the first candidate, the subsequent candidates are ignored - .filter(([k, v]) => k !== v || k.length > 1) // remove “char => the same char” convertions to reduce file size + .filter(([k, v]) => k !== v || [...k].length > 1) // remove “char => the same char” convertions to reduce file size .map(([k, v]) => k + ' ' + v) .join('|'); const outputFile = getAbsPath(`./dist/esm-lib/dict/${fileName}.js`);