File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,21 @@ import { fileURLToPath } from "url";
88const __filename = fileURLToPath ( import . meta. url ) ;
99const __dirname = path . dirname ( __filename ) ;
1010
11+ // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#escape_sequences
12+ const jsonEscape : { [ key : string ] : string } = {
13+ "0000" : "\\0" ,
14+ "0027" : "\\'" ,
15+ "0022" : '\\"' ,
16+ "005C" : "\\\\" ,
17+ "000A" : "\\n" ,
18+ "000D" : "\\r" ,
19+ "000B" : "\\v" ,
20+ "0009" : "\\t" ,
21+ "0008" : "\\b" ,
22+ "000c" : "\\f" ,
23+ } ;
24+
25+
1126type SearchEntry = {
1227 code : string ;
1328 name: string ;
@@ -235,6 +250,19 @@ async function main() {
235250 console . log ( `INFO: name-alias data: ${ JSON . stringify ( charData [ 'name-alias' ] ) } ` ) ;
236251 }
237252
253+ const jse = jsonEscape [ charData . cp ] ;
254+ if ( jse ) {
255+ notes . push ( `JSON escape: '${ jse } '` ) ;
256+ }
257+
258+ const str = String . fromCodePoint ( parseInt ( charData . cp , 16 ) ) ;
259+ if ( encodeURI ( str ) == str ) {
260+ tags . push ( `URI-safe` ) ;
261+ }
262+ if ( encodeURIComponent ( str ) == str ) {
263+ tags . push ( `URIComponent-safe` ) ;
264+ }
265+
238266 entries . push ( {
239267 code : charData . cp ,
240268 name : name || "(no name)" ,
You can’t perform that action at this time.
0 commit comments