@@ -19,10 +19,24 @@ const findCanonicalName = function(shortName) {
1919 return canonicalName ;
2020} ;
2121
22+ const initialMapForType = function ( type ) {
23+ switch ( type ) {
24+ case 'scripts' :
25+ return {
26+ Unknown : regenerate ( ) . addRange ( 0 , CODEPOINT_MAX ) ,
27+ } ;
28+ default :
29+ return { } ;
30+ }
31+ } ;
32+
33+ /**
34+ * @param {'blocks' | 'bidi-mirroring' | 'derived-binary-properties' | 'derived-core-properties' | 'derived-general-category' | 'scripts' } type
35+ * @param {string } version
36+ * @returns
37+ */
2238const parseBlocksScriptsProperties = function ( type , version ) {
23- // `type` is 'properties', 'derived-binary-properties', 'derived-core-properties', 'derived-general-category', 'scripts', 'blocks',
24- // or 'bidi-mirroring'.
25- const map = { } ;
39+ const map = initialMapForType ( type ) ;
2640 const source = utils . readDataFile ( version , type ) ;
2741 if ( ! source ) {
2842 return ;
@@ -75,12 +89,17 @@ const parseBlocksScriptsProperties = function(type, version) {
7589 map [ item ] ??= regenerate ( ) ;
7690 const rangeParts = charRange . split ( '-' ) ;
7791 if ( rangeParts . length == 2 ) {
78- map [ item ] . addRange (
79- parseInt ( rangeParts [ 0 ] , 16 ) ,
80- parseInt ( rangeParts [ 1 ] , 16 )
81- ) ;
92+ const start = parseInt ( rangeParts [ 0 ] , 16 ) , end = parseInt ( rangeParts [ 1 ] , 16 ) ;
93+ map [ item ] . addRange ( start , end ) ;
94+ if ( type == 'scripts' ) {
95+ map . Unknown . removeRange ( start , end ) ;
96+ }
8297 } else {
83- map [ item ] . add ( parseInt ( charRange , 16 ) ) ;
98+ const codepoint = parseInt ( charRange , 16 ) ;
99+ map [ item ] . add ( codepoint ) ;
100+ if ( type == 'scripts' ) {
101+ map . Unknown . remove ( codepoint ) ;
102+ }
84103 }
85104 }
86105 return map ;
@@ -282,9 +301,9 @@ const parseProperties = function (version) {
282301 currentProperty = maybeProperty [ 1 ] ;
283302 if (
284303 // ignore Bidi_Class as they have been generated from UnicodeData
285- currentProperty . startsWith ( "Bidi:" ) ||
304+ currentProperty . startsWith ( "Bidi:" ) ||
286305 // ignore Not a Character and Unassigned Code Value as they have been generated from UnicodeData
287- currentProperty === "Not a Character" ||
306+ currentProperty === "Not a Character" ||
288307 currentProperty === "Unassigned Code Value"
289308 ) {
290309 // skip contents
0 commit comments