Skip to content

Commit bd41213

Browse files
JLHwungmathiasbynens
authored andcommitted
Assign the Unicode 1.1.5 CJK compatibility ideographs
UnicodeData-1.1.5 omits F900..FA2D entirely, so the gap logic reported them as unassigned. The Unicode 1.1 Han cross-reference table (CJKXREF.TXT) lists the whole range, and Unicode 2.0 lists it as Lo. Assisted-By: Claude Opus 5.5 Issue: #110
1 parent 7a7548d commit bd41213

2 files changed

Lines changed: 49 additions & 9 deletions

File tree

‎scripts/parse-blocks-scripts-properties.mjs‎

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ const parseDerivedBinaryProperties = async (version) => {
159159
}
160160
};
161161

162+
// The General_Category values a legacy UnicodeData record contributes to.
163+
const legacyCategoriesOf = (generalCategory) => {
164+
const categories = [
165+
categoryAliases.get(generalCategory),
166+
categoryAliases.get(generalCategory.charAt(0)),
167+
'Assigned',
168+
];
169+
if (/^(?:Ll|Lu|Lt)$/.test(generalCategory)) {
170+
categories.push(categoryAliases.get('LC'));
171+
}
172+
return categories;
173+
};
174+
162175
const parseDerivedGeneralCategory = async (version) => {
163176
if (
164177
version === '3.0.1' ||
@@ -200,15 +213,7 @@ const parseDerivedGeneralCategory = async (version) => {
200213
const codePoint = parseInt(data[0], 16);
201214
const name = data[1];
202215
const recordEnd = representativeRangeEnds.get(name) ?? codePoint;
203-
const generalCategory = data[2];
204-
const categories = [
205-
categoryAliases.get(generalCategory),
206-
categoryAliases.get(generalCategory.charAt(0)),
207-
'Assigned',
208-
];
209-
if (/^(?:Ll|Lu|Lt)$/.test(generalCategory)) {
210-
categories.push(categoryAliases.get('LC'));
211-
}
216+
const categories = legacyCategoriesOf(data[2]);
212217
for (const category of categories) {
213218
categoryMap[category] ??= regenerate();
214219
}
@@ -254,6 +259,27 @@ const parseDerivedGeneralCategory = async (version) => {
254259
}
255260
}
256261

262+
// Assigned ranges that a legacy UnicodeData file leaves out entirely.
263+
const unlistedRanges = [];
264+
if (version === '1.1.5') {
265+
// UnicodeData-1.1.5 omits the CJK Compatibility Ideographs, which the
266+
// Unicode 1.1 Han cross-reference table lists as F900..FA2D.
267+
unlistedRanges.push([0xf900, 0xfa2d, 'Lo']);
268+
}
269+
for (const [start, end, generalCategory] of unlistedRanges) {
270+
// Undo the gap handling, which recorded the range as unassigned.
271+
for (const category of [
272+
categoryAliases.get('C'),
273+
categoryAliases.get('Cn'),
274+
]) {
275+
categoryMap[category].removeRange(start, end);
276+
}
277+
for (const category of legacyCategoriesOf(generalCategory)) {
278+
categoryMap[category] ??= regenerate();
279+
categoryMap[category].addRange(start, end);
280+
}
281+
}
282+
257283
return categoryMap;
258284
} else {
259285
const map = await parseBlocksScriptsProperties(

‎tests/parsers.mjs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,20 @@ test('Unicode 1.1.5 assigns the Unified Han range represented by U+4E00', async
172172
t.assert.ok(!categories.Assigned.contains(0x9fa6));
173173
});
174174

175+
test('Unicode 1.1.5 assigns the unlisted CJK compatibility ideographs', async (t) => {
176+
const categories = await parseDerivedGeneralCategory('1.1.5');
177+
for (const cp of [0xf900, 0xfa0e, 0xfa2d]) {
178+
t.assert.ok(categories.Other_Letter.contains(cp), cp.toString(16));
179+
t.assert.ok(categories.Letter.contains(cp), cp.toString(16));
180+
t.assert.ok(categories.Assigned.contains(cp), cp.toString(16));
181+
t.assert.ok(!categories.Unassigned.contains(cp), cp.toString(16));
182+
t.assert.ok(!categories.Other.contains(cp), cp.toString(16));
183+
}
184+
for (const cp of [0xf8ff, 0xfa2e]) {
185+
t.assert.ok(categories.Unassigned.contains(cp), cp.toString(16));
186+
}
187+
});
188+
175189
test('Bidi class applies historical and current unassigned defaults', async (t) => {
176190
for (const version of [
177191
'3.0.0',

0 commit comments

Comments
 (0)