Skip to content

Commit 6483160

Browse files
JLHwungmathiasbynens
authored andcommitted
Split case-folding expansions on whitespace runs
Assisted-By: GPT-6 Issue: #110
1 parent 44481fb commit 6483160

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎scripts/parse-case-folding.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const parseCaseFolding = async (version) => {
1717
const status = data[1].trim();
1818
const mappings = data[2]
1919
.trim()
20-
.split(' ')
20+
.split(/\s+/)
2121
.map((cp) => parseInt(cp, 16)); // Note: this could be two characters!
2222
if (!caseFoldingMap[status]) {
2323
caseFoldingMap[status] = new Map();

‎tests/parser-formats.mjs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@ import parseBidiBrackets from '../scripts/parse-bidi-brackets.mjs';
66
import parseNameAliases from '../scripts/parse-name-aliases.mjs';
77
import parseSimpleCaseMapping from '../scripts/parse-simple-case-mapping.mjs';
88
import parseJoiningType from '../scripts/parse-joining-type.mjs';
9+
import parseCaseFolding from '../scripts/parse-case-folding.mjs';
910
import {
1011
parseBlocks,
1112
parseDerivedCoreProperties,
1213
} from '../scripts/parse-blocks-scripts-properties.mjs';
1314
import utils from '../scripts/utils.mjs';
1415

16+
test('Case-folding expansions accept runs of whitespace between code points', async (t) => {
17+
let source;
18+
t.mock.method(utils, 'readDataFile', () => source);
19+
for (const separator of [' ', ' ', '\t', ' \t ']) {
20+
source = `0130; F; 0069${separator}0307; # I WITH DOT\n0041; C; 0061; # A\n`;
21+
const map = await parseCaseFolding('18.0.0');
22+
t.assert.deepEqual(map.F.get(0x130), [0x69, 0x307]);
23+
t.assert.equal(map.C.get(0x41), 0x61);
24+
}
25+
});
26+
1527
test('Explicit Non_Joining records remain in the default joining set', async (t) => {
1628
t.mock.method(utils, 'readDataFile', (version, type) =>
1729
type === 'derived-joining-type'

0 commit comments

Comments
 (0)