@@ -15,11 +15,11 @@ const findCanonicalName = (shortName) => {
1515 return canonicalName ;
1616} ;
1717
18- const initialMapForType = ( type ) => {
18+ const initialMapForType = ( type , defaultScript ) => {
1919 switch ( type ) {
2020 case 'scripts' :
2121 return {
22- Unknown : regenerate ( ) . addRange ( 0 , CODEPOINT_MAX ) ,
22+ [ defaultScript ] : regenerate ( ) . addRange ( 0 , CODEPOINT_MAX ) ,
2323 } ;
2424 default :
2525 return { } ;
@@ -32,7 +32,9 @@ const initialMapForType = (type) => {
3232 * @returns
3333 */
3434const parseBlocksScriptsProperties = async ( type , version ) => {
35- const map = initialMapForType ( type ) ;
35+ // Script=Unknown was introduced in Unicode 5.0. Earlier releases use Common.
36+ const defaultScript = parseInt ( version , 10 ) < 5 ? 'Common' : 'Unknown' ;
37+ const map = initialMapForType ( type , defaultScript ) ;
3638 const source = utils . readDataFile ( version , type ) ;
3739 if ( ! source ) {
3840 return ;
@@ -89,14 +91,14 @@ const parseBlocksScriptsProperties = async (type, version) => {
8991 const start = parseInt ( rangeParts [ 0 ] , 16 ) ;
9092 const end = parseInt ( rangeParts [ 1 ] , 16 ) ;
9193 map [ item ] . addRange ( start , end ) ;
92- if ( type === 'scripts' ) {
93- map . Unknown . removeRange ( start , end ) ;
94+ if ( type === 'scripts' && item !== defaultScript ) {
95+ map [ defaultScript ] . removeRange ( start , end ) ;
9496 }
9597 } else {
9698 const codepoint = parseInt ( charRange , 16 ) ;
9799 map [ item ] . add ( codepoint ) ;
98- if ( type === 'scripts' ) {
99- map . Unknown . remove ( codepoint ) ;
100+ if ( type === 'scripts' && item !== defaultScript ) {
101+ map [ defaultScript ] . remove ( codepoint ) ;
100102 }
101103 }
102104 }
0 commit comments