-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharDisplay.py
executable file
·2100 lines (1942 loc) · 98.4 KB
/
CharDisplay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
#
# CharDisplay.py: Show tons of info about a character(s).
# 2018-04-21: Written by Steven J. DeRose
#
#pylint: disable=I1101
#
import sys
import argparse
import unicodedata
import re
import string
from enum import Enum
from typing import List
from urllib.parse import quote as urlquote
from urllib.parse import unquote as urlunquote
from urllib.request import urlopen
from html.entities import codepoint2name, name2codepoint
from html import unescape
import logging
lg = logging.getLogger("CharDisplay")
__metadata__ = {
"title" : "CharDisplay",
"description" : "Show tons of info about a character(s).",
"rightsHolder" : "Steven J. DeRose",
"creator" : "http://viaf.org/viaf/50334488",
"type" : "http://purl.org/dc/dcmitype/Software",
"language" : "Python 2.7.6, 3.6",
"created" : "2018-04-21",
"modified" : "2023-02-21",
"publisher" : "http://github.com/sderose",
"license" : "https://creativecommons.org/licenses/by-sa/3.0/"
}
__version__ = __metadata__["modified"]
descr = """
=Description=
Display detailed information about a single Unicode character.
Can be used as a library, or from the command line to identify characters
by their code points, or the literal character:
CharDisplay 65 0x2400 012 x
This accepts decimal, hex, and octal code point numbers, as well
as literal characters (all shown in the example above).
However, it does not support specifying characters by their HTML entity name,
Unicode full name, Unix jargon name, etc. (for which see my `ord`).
==Legend==
An example display, for U+FB00 when using this as a command, is:
Unicode Name LATIN SMALL LIGATURE FF
Script Latin
Category "Ll" (Letter, Lowercase)
Block Alphabetic Presentation Forms
Plane 0: Basic Multilingual
Literal ",,xEF,,xAC,,x80"
Bases o001754000 d064256 0xfb00
Unicode U+fb00, utf8 \\xefac80 URI %EF%AC%80 (URI? False; FPI? False)
Entities ff ff None
Unix jargon
Numeric value
Is Bidi L
Is Combining
ea width N
IsMirror
Decompose <compat> 0066 0066
Normalizations NFC "\\xEF\\xAC\\x80", NFKC "ff", NFD "\\xEF\\xAC\\x80", NFD "ff"
There is a `--python` option to write some info as Python literal inits, but
for such uses, see `strfchr.py` instead.
==Notes on some parts:==
* Category: A 2-letter name defined by the Unicode standard,
saying what "kind" of character it is.
To see a list, use `--help-categories`.
* '''Literal''': The character itself. How this shows up depends on your
terminal program and settings, shell capabilities, etc.
* '''Unicode''': Shows several ways to express the character. "U+xxxx" is
commonly used in print; the UTF-8 equivalent is given as a series of hex
digits; the same UTF-8 is also given with each byte %-escaped as it would
be in a URL. Finally, there is a note to indicate whether the character is
allowed or not within URLs (without being escaped); that will show "False"
for all non-ASCII characters, and for quite a few ASCII punctuation marks.
* '''Entities''': Shows ways to express the character (other than literally)
within XML or HTML. If HTML 4 defines a named entity for the character,
that is shown last (otherwise, "None")
* '''Unix''' jargon: This shows traditional ways of referring to the character
other than the official Unicode name (if any).
* '''eawidth''':
* '''width''':
* '''NumericValue''': Many unicode characters represent numbers. The most
obvious are the digits 0-9, but there are also
digits in many other scripts;
circled, parenthesized, superscript, or otherwise special digits;
Roman Numerals; fractions; and so on. This line gives the numeric
value associated with the character. For some fractions such
as 1/7, the value is approximate. A few characters that one might expect
to have numeric values, such as pi and Euler's constant. do not.
* '''IsURI''':
* '''IsFPI''':
* '''IsBidi''':
* '''IsCombining''':
* '''IsCombined''':
* '''IsMirror''':
* '''MirrorOf''':
* '''Decomp''': The decomposition of the character, according to
NFD and NFKD, but shown as code points for the individual characters.
* '''Normalizations''': Unicode defines 4 different "normalized" forms
(they are availabe in Python via `unicodedata.normalize(form, [which])`),
for [which] in 'NFC', 'NFD', 'NFKC', or 'NFKD'
(see [https://docs.python.org/2/library/unicodedata.html]:
The forms with "K" use compatibility equivalence: certain characters are
unified with other characters.
For example, U+2160 (ROMAN NUMERAL ONE) and U+0049
(LATIN CAPITAL LETTER I).
Compatibility composition does ''not'' merge characters such as uppercase
English A and Greek alpha, or even soft hyphen. However, forms NKFC and
NFKD do normalize non-breaking space to regular space.
* If the code point is in the range 0x80 to 0xFF, an additional line is displayed
saying what that code point is in the "Mac Roman" character set, and what the
Unicode code point for ''that'' is (unless you set `--nomac`).
=Related Commands=
My `ord`, `chr`, `countChars`, `strfchr.py`.
=Known Bugs and Limitations=
Unicode category names do not display correctly (though mnemonics do).
=To do=
* Option to sanity-check types/values generated, via CProps info.
=Rights=
Copyright 2015 by Steven J. DeRose. This work is licensed under a Creative Commons
Attribution-Share Alike 3.0 Unported License. For further information on
this license, see [http://creativecommons.org/licenses/by-sa/3.0].
For the most recent version, see [http://www.derose.net/steve/utilities] or
[http://github.com/sderose].
=History=
* 2018-04-21: Written by Steven J. DeRose.
* 2018-10-02: Make Py 2/3 compatible. Support --cat for single letters.
Make it avoid non-Unicode (hence nameless) code points. Add --python.
* 2018-11-16: Fix hex display of Unicode normalized forms. Fix html and urllib
includes.
* 2020-02-12: New layout conventions.
* 2021-04-09ff: Enumerate prop names and sync with strfchr.py.
Accept string and other arguments, not just codepoints.
Change property internal names to uppercase. Drop redundant data.
Add actual names for C0 control chars (not just mnemonics).
* 2021-07-09: Add protectDisplay() to avoid displaying literal control chars
or other troublesome ones.
* 2021-07-23: Add MacRoman from Perl `chr`, display it when applicable, and provide
--nomac to suppress.
* 2023-02-21: Drop last Py2 support. Add POSIX regex categories. Switch
charProperties to CProps enum.
* 2023-09-20: Clean up error handling. Fix command-line processing.
=Options=
"""
###############################################################################
# (Data also available in tupleSets/cp1252.xsv, and in "chr")
#
cp1252ToUnicode = {
0x80 : 0x20AC, # EURO SIGN
# 0x81 UNUSED
0x82 : 0x201A, # SINGLE LOW-9 QUOTATION MARK
0x83 : 0x0192, # LATIN SMALL LETTER F WITH HOOK
0x84 : 0x201E, # DOUBLE LOW-9 QUOTATION MARK
0x85 : 0x2026, # HORIZONTAL ELLIPSIS
0x86 : 0x2020, # DAGGER
0x87 : 0x2021, # DOUBLE DAGGER
0x88 : 0x02C6, # MODIFIER LETTER CIRCUMFLEX ACCENT
0x89 : 0x2030, # PER MILLE SIGN
0x8A : 0x0160, # LATIN CAPITAL LETTER S WITH CARON
0x8B : 0x2039, # SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x8C : 0x0152, # LATIN CAPITAL LIGATURE OE
# 0x8D UNUSED
0x8E : 0x017D, # LATIN CAPITAL LETTER Z WITH CARON
# 0x8F UNUSED
# 0x90 UNUSED
0x91 : 0x2018, # LEFT SINGLE QUOTATION MARK
0x92 : 0x2019, # RIGHT SINGLE QUOTATION MARK
0x93 : 0x201C, # LEFT DOUBLE QUOTATION MARK
0x94 : 0x201D, # RIGHT DOUBLE QUOTATION MARK
0x95 : 0x2022, # BULLET
0x96 : 0x2013, # EN DASH
0x97 : 0x2014, # EM DASH
0x98 : 0x02DC, # SMALL TILDE
0x99 : 0x2122, # TRADE MARK SIGN
0x9A : 0x0161, # LATIN SMALL LETTER S WITH CARON
0x9B : 0x203A, # SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x9C : 0x0153, # LATIN SMALL LIGATURE OE
# 0x9D UNUSED
0x9E : 0x017E, # LATIN SMALL LETTER Z WITH CARON
0x9F : 0x0178, # LATIN CAPITAL LETTER Y WITH DIAERESIS
}
###############################################################################
# See http://en.wikipedia.org/wiki/Mac_OS_Roman
# (from Perl code in "chr")
#
macRomanData = {
# mac: ( Unucode Entity Unicode Name
####### C1 #######
0x80 : ( 0x00C4, "Auml", "LATIN CAPITAL LETTER A WITH DIAERESIS", ),
0x81 : ( 0x00C5, "Aring", "LATIN CAPITAL LETTER A WITH RING ABOVE", ),
0x82 : ( 0x00C7, "Ccedil", "LATIN CAPITAL LETTER C WITH CEDILLA", ),
0x83 : ( 0x00C9, "Eacute", "LATIN CAPITAL LETTER E WITH ACUTE", ),
0x84 : ( 0x00D1, "Ntilde", "LATIN CAPITAL LETTER N WITH TILDE", ),
0x85 : ( 0x00D6, "Ouml", "LATIN CAPITAL LETTER O WITH DIAERESIS", ),
0x86 : ( 0x00DC, "Uuml", "LATIN CAPITAL LETTER U WITH DIAERESIS", ),
0x87 : ( 0x00E1, "aacute", "LATIN SMALL LETTER A WITH ACUTE", ),
0x88 : ( 0x00E0, "agrave", "LATIN SMALL LETTER A WITH GRAVE", ),
0x89 : ( 0x00E2, "acirc", "LATIN SMALL LETTER A WITH CIRCUMFLEX", ),
0x8A : ( 0x00E4, "auml", "LATIN SMALL LETTER A WITH DIAERESIS", ),
0x8B : ( 0x00E3, "atilde", "LATIN SMALL LETTER A WITH TILDE", ),
0x8C : ( 0x00E5, "aring", "LATIN SMALL LETTER A WITH RING ABOVE", ),
0x8D : ( 0x00E7, "ccedil", "LATIN SMALL LETTER C WITH CEDILLA", ),
0x8E : ( 0x00E9, "eacute", "LATIN SMALL LETTER E WITH ACUTE", ),
0x8F : ( 0x00E8, "egrave", "LATIN SMALL LETTER E WITH GRAVE", ),
0x90 : ( 0x00EA, "ecirc", "LATIN SMALL LETTER E WITH CIRCUMFLEX", ),
0x91 : ( 0x00EB, "euml", "LATIN SMALL LETTER E WITH DIAERESIS", ),
0x92 : ( 0x00ED, "iacute", "LATIN SMALL LETTER I WITH ACUTE", ),
0x93 : ( 0x00EC, "igrave", "LATIN SMALL LETTER I WITH GRAVE", ),
0x94 : ( 0x00EE, "icirc", "LATIN SMALL LETTER I WITH CIRCUMFLEX", ),
0x95 : ( 0x00EF, "iuml", "LATIN SMALL LETTER I WITH DIAERESIS", ),
0x96 : ( 0x00F1, "ntilde", "LATIN SMALL LETTER N WITH TILDE", ),
0x97 : ( 0x00F3, "oacute", "LATIN SMALL LETTER O WITH ACUTE", ),
0x98 : ( 0x00F2, "ograve", "LATIN SMALL LETTER O WITH GRAVE", ),
0x99 : ( 0x00F4, "ocirc", "LATIN SMALL LETTER O WITH CIRCUMFLEX", ),
0x9A : ( 0x00F6, "ouml", "LATIN SMALL LETTER O WITH DIAERESIS", ),
0x9B : ( 0x00F5, "otilde", "LATIN SMALL LETTER O WITH TILDE", ),
0x9C : ( 0x00FA, "uacute", "LATIN SMALL LETTER U WITH ACUTE", ),
0x9D : ( 0x00F9, "ugrave", "LATIN SMALL LETTER U WITH GRAVE", ),
0x9E : ( 0x00FB, "ucirc", "LATIN SMALL LETTER U WITH CIRCUMFLEX", ),
0x9F : ( 0x00FC, "uuml", "LATIN SMALL LETTER U WITH DIAERESIS", ),
####### G1 #######
0xA0 : ( 0x2020, "dagger", "DAGGER", ),
0xA1 : ( 0x00B0, "deg", "DEGREE SIGN", ),
0xA2 : ( 0x00A2, "cent", "CENT SIGN", ),
0xA3 : ( 0x00A3, "pound", "POUND SIGN", ),
0xA4 : ( 0x00A7, "sect", "SECTION SIGN", ),
0xA5 : ( 0x2022, "bull", "BULLET", ),
0xA6 : ( 0x00B6, "para", "PILCROW SIGN", ),
0xA7 : ( 0x00DF, "szlig", "LATIN SMALL LETTER SHARP S", ),
0xA8 : ( 0x00AE, "reg", "REGISTERED SIGN", ),
0xA9 : ( 0x00A9, "copy", "COPYRIGHT SIGN", ),
0xAA : ( 0x2122, "trade", "TRADE MARK SIGN", ),
0xAB : ( 0x00B4, "acute", "ACUTE ACCENT", ),
0xAC : ( 0x00A8, "uml", "DIAERESIS", ),
0xAD : ( 0x2260, "ne", "NOT EQUAL TO", ),
0xAE : ( 0x00C6, "AElig", "LATIN CAPITAL LETTER AE", ),
0xAF : ( 0x00D8, "Oslash", "LATIN CAPITAL LETTER O WITH STROKE", ),
0xB0 : ( 0x221E, "infin", "INFINITY", ),
0xB1 : ( 0x00B1, "plusmn", "PLUS-MINUS SIGN", ),
0xB2 : ( 0x2264, "le", "LESS-THAN OR EQUAL TO", ),
0xB3 : ( 0x2265, "ge", "GREATER-THAN OR EQUAL TO", ),
0xB4 : ( 0x00A5, "yen", "YEN SIGN", ),
0xB5 : ( 0x00B5, "micro", "MICRO SIGN", ),
0xB6 : ( 0x2202, "part", "PARTIAL DIFFERENTIAL", ),
0xB7 : ( 0x2211, "sum", "N-ARY SUMMATION", ),
0xB8 : ( 0x220F, "prod", "N-ARY PRODUCT", ),
0xB9 : ( 0x03C0, "pi", "GREEK SMALL LETTER PI", ),
0xBA : ( 0x222B, "int", "INTEGRAL", ),
0xBB : ( 0x00AA, "ordf", "FEMININE ORDINAL INDICATOR", ),
0xBC : ( 0x00BA, "ordm", "MASCULINE ORDINAL INDICATOR", ),
0xBD : ( 0x03A9, "Omega", "GREEK CAPITAL LETTER OMEGA", ),
0xBE : ( 0x00E6, "aelig", "LATIN SMALL LETTER AE", ),
0xBF : ( 0x00F8, "oslash", "LATIN SMALL LETTER O WITH STROKE", ),
0xC0 : ( 0x00BF, "iquest", "INVERTED QUESTION MARK", ),
0xC1 : ( 0x00A1, "iexcl", "INVERTED EXCLAMATION MARK", ),
0xC2 : ( 0x00AC, "not", "NOT SIGN", ),
0xC3 : ( 0x221A, "radic", "SQUARE ROOT", ),
0xC4 : ( 0x0192, "fnof", "LATIN SMALL LETTER F WITH HOOK", ),
0xC5 : ( 0x2248, "asymp", "ALMOST EQUAL TO", ),
0xC6 : ( 0x2206, "", "INCREMENT", ),
0xC7 : ( 0x00AB, "laquo", "LEFT-POINTING DOUBLE ANGLE QUOTATION MARK", ),
0xC8 : ( 0x00BB, "raquo", "RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK", ),
0xC9 : ( 0x2026, "hellip", "HORIZONTAL ELLIPSIS", ),
0xCA : ( 0x00A0, "nbsp", "NO-BREAK SPACE", ),
0xCB : ( 0x00C0, "Agrave", "LATIN CAPITAL LETTER A WITH GRAVE", ),
0xCC : ( 0x00C3, "Atilde", "LATIN CAPITAL LETTER A WITH TILDE", ),
0xCD : ( 0x00D5, "Otilde", "LATIN CAPITAL LETTER O WITH TILDE", ),
0xCE : ( 0x0152, "OElig", "LATIN CAPITAL LIGATURE OE", ),
0xCF : ( 0x0153, "oelig", "LATIN SMALL LIGATURE OE", ),
0xD0 : ( 0x2013, "ndash", "EN DASH", ),
0xD1 : ( 0x2014, "mdash", "EM DASH", ),
0xD2 : ( 0x201C, "ldquo", "LEFT DOUBLE QUOTATION MARK", ),
0xD3 : ( 0x201D, "rdquo", "RIGHT DOUBLE QUOTATION MARK", ),
0xD4 : ( 0x2018, "lsquo", "LEFT SINGLE QUOTATION MARK", ),
0xD5 : ( 0x2019, "rsquo", "RIGHT SINGLE QUOTATION MARK", ),
0xD6 : ( 0x00F7, "divide", "DIVISION SIGN", ),
0xD7 : ( 0x25CA, "loz", "LOZENGE", ),
0xD8 : ( 0x00FF, "yuml", "LATIN SMALL LETTER Y WITH DIAERESIS", ),
0xD9 : ( 0x0178, "Yuml", "LATIN CAPITAL LETTER Y WITH DIAERESIS", ),
0xDA : ( 0x2044, "frasl", "FRACTION SLASH", ),
0xDB : ( 0x20AC, "euro", "EURO SIGN", ),
0xDC : ( 0x2039, "lsaquo", "SINGLE LEFT-POINTING ANGLE QUOTATION MARK", ),
0xDD : ( 0x203A, "rsaquo", "SINGLE RIGHT-POINTING ANGLE QUOTATION MARK", ),
0xDE : ( 0xFB01, "", "LATIN SMALL LIGATURE FI", ),
0xDF : ( 0xFB02, "", "LATIN SMALL LIGATURE FL", ),
0xE0 : ( 0x2021, "Dagger", "DOUBLE DAGGER", ),
0xE1 : ( 0x00B7, "middot", "MIDDLE DOT", ),
0xE2 : ( 0x201A, "sbquo", "SINGLE LOW-9 QUOTATION MARK", ),
0xE3 : ( 0x201E, "bdquo", "DOUBLE LOW-9 QUOTATION MARK", ),
0xE4 : ( 0x2030, "permil", "PER MILLE SIGN", ),
0xE5 : ( 0x00C2, "Acirc", "LATIN CAPITAL LETTER A WITH CIRCUMFLEX", ),
0xE6 : ( 0x00CA, "Ecirc", "LATIN CAPITAL LETTER E WITH CIRCUMFLEX", ),
0xE7 : ( 0x00C1, "Aacute", "LATIN CAPITAL LETTER A WITH ACUTE", ),
0xE8 : ( 0x00CB, "Euml", "LATIN CAPITAL LETTER E WITH DIAERESIS", ),
0xE9 : ( 0x00C8, "Egrave", "LATIN CAPITAL LETTER E WITH GRAVE", ),
0xEA : ( 0x00CD, "Iacute", "LATIN CAPITAL LETTER I WITH ACUTE", ),
0xEB : ( 0x00CE, "Icirc", "LATIN CAPITAL LETTER I WITH CIRCUMFLEX", ),
0xEC : ( 0x00CF, "Iuml", "LATIN CAPITAL LETTER I WITH DIAERESIS", ),
0xED : ( 0x00CC, "Igrave", "LATIN CAPITAL LETTER I WITH GRAVE", ),
0xEE : ( 0x00D3, "Oacute", "LATIN CAPITAL LETTER O WITH ACUTE", ),
0xEF : ( 0x00D4, "Ocirc", "LATIN CAPITAL LETTER O WITH CIRCUMFLEX", ),
# WARNING: Apple uses U+F8FF for their logo, but that's private-use.
0xF0 : ( 0xF8FF, "", "APPLE LOGO", ),
0xF1 : ( 0x00D2, "Ograve", "LATIN CAPITAL LETTER O WITH GRAVE", ),
0xF2 : ( 0x00DA, "Uacute", "LATIN CAPITAL LETTER U WITH ACUTE", ),
0xF3 : ( 0x00DB, "Ucirc", "LATIN CAPITAL LETTER U WITH CIRCUMFLEX", ),
0xF4 : ( 0x00D9, "Ugrave", "LATIN CAPITAL LETTER U WITH GRAVE", ),
0xF5 : ( 0x0131, "", "LATIN SMALL LETTER DOTLESS I", ),
0xF6 : ( 0x02C6, "circ", "MODIFIER LETTER CIRCUMFLEX ACCENT", ),
0xF7 : ( 0x02DC, "tilde", "SMALL TILDE", ),
0xF8 : ( 0x00AF, "macr", "MACRON", ),
0xF9 : ( 0x02D8, "", "BREVE", ),
0xFA : ( 0x02D9, "", "DOT ABOVE", ),
0xFB : ( 0x02DA, "", "RING ABOVE", ),
0xFC : ( 0x00B8, "cedil", "CEDILLA", ),
0xFD : ( 0x02DD, "", "DOUBLE ACUTE ACCENT", ),
0xFE : ( 0x02DB, "", "OGONEK", ),
0xFF : ( 0x02C7, "", "CARON", ),
} # macRomanData
assert len(macRomanData) == 128
# TODO: Move to separate test process
for i in sorted(macRomanData.keys()):
if (i<128 or i>255 or len(macRomanData[i]) != 3):
lg.critical("macRomanData table error, entry %d is %s", i, repr(macRomanData[i]))
sys.exit()
ucp, ent, nam = macRomanData[i]
if ((not isinstance(ucp, int)) or ucp < 0XA0 or ucp > 0xFB02):
raise ValueError(
"macRomanData[%04x]: Unicode equivalent %04x out of range." % (i, ucp))
if (ent):
cpOfEntity = name2codepoint[ent]
if (cpOfEntity != ucp):
raise ValueError(
"macRomanData[%04x]: entity '%s' maps to %04x ('%s'), not %04x." %
(i, ent, cpOfEntity, codepoint2name[cpOfEntity], ucp))
if (not re.match(r"[- A-Z0-9]{5,}$", nam)):
raise ValueError("macRomanData for %04x: bad name '%s'." % (i, nam))
ASCII = [
#Dec, Lit|Mnem, Name, Hex, fpiOK,uriOK
#
[ 0, "NUL", "NULL", 0x00, "-", "-" ],
[ 1, "SOH", "Start of Heading", 0x01, "-", "-" ],
[ 2, "STX", "End of heading", 0x02, "-", "-" ],
[ 3, "ETX", "End of text", 0x03, "-", "-" ],
[ 4, "EOT", "End of transmission", 0x04, "-", "-" ],
[ 5, "ENQ", "Enquiry", 0x05, "-", "-" ],
[ 6, "ACK", "Acknowledge", 0x06, "-", "-" ],
[ 7, "BEL", "Bell", 0x07, "-", "-" ],
[ 8, "BS", "Backspace", 0x08, "-", "-" ],
[ 9, "TAB","Horizontal tabulation", 0x09, "-", "-" ],
[ 10, "LF", "Line feed", 0x0A, "+", "-" ],
[ 11, "VT", "Vertical tabulation", 0x0B, "-", "-" ],
[ 12, "FF", "Form feed", 0x0C, "-", "-" ],
[ 13, "CR", "Carriage return", 0x0D, "+", "-" ],
[ 14, "SO", "Shift out", 0x0E, "-", "-" ],
[ 15, "SI", "Shift in", 0x0F, "-", "-" ],
[ 16, "DLE", "Data link escape", 0x10, "-", "-" ],
[ 17, "DC1", "Device control 1", 0x11, "-", "-" ],
[ 18, "DC2", "Device control 2", 0x12, "-", "-" ],
[ 19, "DC3", "Device control 3", 0x13, "-", "-" ],
[ 20, "DC4", "Device control 4", 0x14, "-", "-" ],
[ 21, "NAK", "Negative acknowledge", 0x15, "-", "-" ],
[ 22, "SYN", "Synchronous Idle", 0x16, "-", "-" ],
[ 23, "ETB", "End of transmission block", 0x17, "-", "-" ],
[ 24, "CAN", "Cancel", 0x18, "-", "-" ],
[ 25, "EM", "End message", 0x19, "-", "-" ],
[ 26, "SUB", "Substitute character", 0x1a, "-", "-" ],
[ 27, "ESC", "Escape", 0x1B, "-", "-" ],
[ 28, "FS", "Field Separator", 0x1c, "-", "-" ],
[ 29, "GS", "Group Separator", 0x1d, "-", "-" ],
[ 30, "RS", "Record Separator", 0x1e, "-", "-" ],
[ 31, "US", "Unit Separator", 0x1f, "-", "-" ],
[ 32, "SPACE","SPACE", 0x20, "+", "-" ],
[ 33, "!", "exclamation mark", 0x21, "-", "+" ],
[ 34, '"', "quotation mark", 0x22, "-", "*" ],
[ 35, "#", "number sign", 0x23, "-", "-" ],
[ 36, "$", "dollar sign", 0x24, "-", "+" ],
[ 37, "%", "percent sign", 0x25, "-", "(escape)" ],
[ 38, "&", "ampersand", 0x26, "-", "*" ],
[ 39, "'", "apostrophe", 0x27, "+", "+" ],
[ 40, "(", "left parenthesis", 0x28, "+", "+" ],
[ 41, ")", "right parenthesis", 0x29, "+", "+" ],
[ 42, "*", 'asterisk', 0x2A, "-", '+' ],
[ 43, "+", "plus sign", 0x2B, "+", "+" ],
[ 44, ",", "comma", 0x2C, "+", "-" ],
[ 45, "-", "hyphen, minus sign", 0x2D, "+", "+" ],
[ 46, ".", "full stop", 0x2E, "+", "+" ],
[ 47, "/", "solidus", 0x2F, "+", "~" ],
[ 48, "0", "digit 0", 0x30, "+", "+" ],
[ 49, "1", "digit 1", 0x31, "+", "+" ],
[ 50, "2", "digit 2", 0x32, "+", "+" ],
[ 51, "3", "digit 3", 0x33, "+", "+" ],
[ 52, "4", "digit 4", 0x34, "+", "+" ],
[ 53, "5", "digit 5", 0x35, "+", "+" ],
[ 54, "6", "digit 6", 0x36, "+", "+" ],
[ 55, "7", "digit 7", 0x37, "+", "+" ],
[ 56, "8", "digit 8", 0x38, "+", "+" ],
[ 57, "9", "digit 9", 0x39, "+", "+" ],
[ 58, ",", "colon", 0x3A, "+", "~" ],
[ 59, ";", "semicolon", 0x3B, "-", "~" ],
[ 60, "<", "less-than sign", 0x3C, "-", "*" ],
[ 61, "=", "equals sign", 0x3D, "+", "~" ],
[ 62, ">", "greater-than sign", 0x3E, "-", "*" ],
[ 63, "?", "question mark", 0x3F, "+", "~" ],
[ 64, "@", "commercial at", 0x40, "-", "~" ],
[ 65, "A", "capital letter A", 0x41, "+", "+" ],
[ 66, "B", "capital letter B", 0x42, "+", "+" ],
[ 67, "C", "capital letter C", 0x43, "+", "+" ],
[ 68, "D", "capital letter D", 0x44, "+", "+" ],
[ 69, "E", "capital letter E", 0x45, "+", "+" ],
[ 70, "F", "capital letter F", 0x46, "+", "+" ],
[ 71, "G", "capital letter G", 0x47, "+", "+" ],
[ 72, "H", "capital letter H", 0x48, "+", "+" ],
[ 73, "I", "capital letter I", 0x49, "+", "+" ],
[ 74, "J", "capital letter J", 0x4A, "+", "+" ],
[ 75, "K", "capital letter K", 0x4B, "+", "+" ],
[ 76, "L", "capital letter L", 0x4C, "+", "+" ],
[ 77, "M", "capital letter M", 0x4D, "+", "+" ],
[ 78, "N", "capital letter N", 0x4E, "+", "+" ],
[ 79, "O", "capital letter O", 0x4F, "+", "+" ],
[ 80, "P", "capital letter P", 0x50, "+", "+" ],
[ 81, "Q", "capital letter Q", 0x51, "+", "+" ],
[ 82, "R", "capital letter R", 0x52, "+", "+" ],
[ 83, "S", "capital letter S", 0x53, "+", "+" ],
[ 84, "T", "capital letter T", 0x54, "+", "+" ],
[ 85, "U", "capital letter U", 0x55, "+", "+" ],
[ 86, "V", "capital letter V", 0x56, "+", "+" ],
[ 87, "W", "capital letter W", 0x57, "+", "+" ],
[ 88, "X", "capital letter X", 0x58, "+", "+" ],
[ 89, "Y", "capital letter Y", 0x59, "+", "+" ],
[ 90, "Z", "capital letter Z", 0x5A, "+", "+" ],
[ 91, "[", "left square bracket", 0x5B, "-", "-" ],
[ 92, "\\", "reverse solidus", 0x5C, "-", "-" ],
[ 93, "]", "right square bracket", 0x5D, "-", "*" ],
[ 94, "^", "circumflex", 0x5E, "-", "-" ],
[ 95, "_", "underscore", 0x5F, "-", "+" ],
[ 96, "`", "grave", 0x60, "-", "-" ],
[ 97, "a", "small letter a", 0x61, "+", "+" ],
[ 98, "b", "small letter b", 0x62, "+", "+" ],
[ 99, "c", "small letter c", 0x63, "+", "+" ],
[ 100, "d", "small letter d", 0x64, "+", "+" ],
[ 101, "e", "small letter e", 0x65, "+", "+" ],
[ 102, "f", "small letter f", 0x66, "+", "+" ],
[ 103, "g", "small letter g", 0x67, "+", "+" ],
[ 104, "h", "small letter h", 0x68, "+", "+" ],
[ 105, "i", "small letter i", 0x69, "+", "+" ],
[ 106, "j", "small letter j", 0x6A, "+", "+" ],
[ 107, "k", "small letter k", 0x6B, "+", "+" ],
[ 108, "l", "small letter l", 0x6C, "+", "+" ],
[ 109, "m", "small letter m", 0x6D, "+", "+" ],
[ 110, "n", "small letter n", 0x6E, "+", "+" ],
[ 111, "o", "small letter o", 0x6F, "+", "+" ],
[ 112, "p", "small letter p", 0x70, "+", "+" ],
[ 113, "q", "small letter q", 0x71, "+", "+" ],
[ 114, "r", "small letter r", 0x72, "+", "+" ],
[ 115, "s", "small letter s", 0x73, "+", "+" ],
[ 116, "t", "small letter t", 0x74, "+", "+" ],
[ 117, "u", "small letter u", 0x75, "+", "+" ],
[ 118, "v", "small letter v", 0x76, "+", "+" ],
[ 119, "w", "small letter w", 0x77, "+", "+" ],
[ 120, "x", "small letter x", 0x78, "+", "+" ],
[ 121, "y", "small letter y", 0x79, "+", "+" ],
[ 122, "z", "small letter z", 0x7A, "+", "+" ],
[ 123, "{", "left curly bracket", 0x7B, "-", "-" ],
[ 124, "|", "vertical bar", 0x7C, "-", "-" ],
[ 125, "}", "right curly bracket", 0x7D, "-", "-" ],
[ 126, "~", "tilde", 0x7E, "-", "-" ],
[ 127, "\xFF", "DELETE or Y WITH DIAERESIS", 0x7F, "-", "-" ],
]
for i in range(0, 128):
if (ASCII[i][0] != i or len(ASCII[i]) != 6):
lg.error("ASCII table error, entry %d is %s", i, repr(ASCII[i]))
sys.exit()
C0Names = [ # Not in unicodedata.name...
"NULL",
"START OF HEADING",
"START OF TEXT",
"END OF TEXT",
"END OF TRANSMISSION",
"ENQUIRY",
"ACKNOWLEDGE",
"BELL",
"BACKSPACE",
"CHARACTER TABULATION",
"LINE FEED (LF)",
"LINE TABULATION",
"FORM FEED (FF)",
"CARRIAGE RETURN (CR)",
"SHIFT OUT",
"SHIFT IN",
"DATA LINK ESCAPE",
"DEVICE CONTROL ONE",
"DEVICE CONTROL TWO",
"DEVICE CONTROL THREE",
"DEVICE CONTROL FOUR",
"NEGATIVE ACKNOWLEDGE",
"SYNCHRONOUS IDLE",
"END OF TRANSMISSION BLOCK",
"CANCEL",
"END OF MEDIUM",
"SUBSTITUTE",
"ESCAPE",
"INFORMATION SEPARATOR FOUR",
"INFORMATION SEPARATOR THREE",
"INFORMATION SEPARATOR TWO",
"INFORMATION SEPARATOR ONE",
]
assert len(C0Names) == 32
# Second string here has special, reserved, etc. chars.
okInUriExpr = r"[%s]" % ("!$'()*+-._0-9A-Za-z" + r'"%&/:;<=>\?@]')
# And for SGML Formal Public Identifiers.
okInFpiExpr = r"[\n\r '()+,-./0-9:=?A-Za-z]"
def okInFPI(n:int) -> bool: return (n<128 and ASCII[n][4] == "+")
def okInURI(n:int) -> bool: return (n<128 and ASCII[n][5] == "+")
C0Mnemonics = [
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US",
"SP"
]
assert len(C0Mnemonics) == 33
C1Mnemonics = [
"PAD", "HOP", "BPH", "NBH", "IND", "NEL", "SSA", "ESA",
"HTS", "HTJ", "VTS", "PLD", "PLU", "RI", "SS2", "SS3",
"DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA",
"SOS", "SGCI", "SCI", "CSI", "ST", "OSC", "PM", "APC",
"NBS"
]
assert len(C1Mnemonics) == 33
# Perhaps should add:
# arrows, dingbats, alpha/syll/ideo, emoji (is that a script?)
# domains: game, music, display, cartography, alchemy
#
###############################################################################
# Unicode "general categories", available via unicodedata.category(c)
# https://stackoverflow.com/questions/1832893/
# regex also supports single-char cover categories, I think.
#
unicodeCategories = { # Replaces categoryAbbr2Name
"C": "Other (all subtypes)",
"L": "Letter (all subtypes)",
"M": "Mark (all subtypes)",
"N": "Number (all subtypes)",
"P": "Punctuation (all subtypes)",
"S": "Symbol (all subtypes)",
"Z": "Separator (all subtypes)",
"Cc": "Other, Control",
"Cf": "Other, Format",
"Cn": "Other, Not Assigned",
"Co": "Other, Private Use",
"Cs": "Other, Surrogate",
"LC": "Letter, Cased",
"Ll": "Letter, Lowercase",
"Lm": "Letter, Modifier",
"Lo": "Letter, Other",
"Lt": "Letter, Titlecase",
"Lu": "Letter, Uppercase",
"Mc": "Mark, Spacing Combining",
"Me": "Mark, Enclosing",
"Mn": "Mark, Nonspacing",
"Nd": "Number, Decimal Digit",
"Nl": "Number, Letter",
"No": "Number, Other",
"Pc": "Punctuation, Connector",
"Pd": "Punctuation, Dash",
"Pe": "Punctuation, Close",
"Pf": "Punctuation, Final quote",
"Pi": "Punctuation, Initial quote",
"Po": "Punctuation, Other",
"Ps": "Punctuation, Open",
"Sc": "Symbol, Currency",
"Sk": "Symbol, Modifier",
"Sm": "Symbol, Math",
"So": "Symbol, Other",
"Zl": "Separator, Line",
"Zp": "Separator, Paragraph",
"Zs": "Separator, Space",
}
if (len(unicodeCategories) != 38):
lg.critical("Bad item count for unicodeCategories: %d.", len(unicodeCategories))
sys.exit()
_blocks = []
def _initBlocks(text):
pattern = re.compile(r"([0-9A-F]+)\.\.([0-9A-F]+);\ (\S.*\S)")
for line in text.splitlines():
m = pattern.match(line)
if m:
start, end, name = m.groups()
_blocks.append((int(start, 16), int(end, 16), name))
# retrieved from http://unicode.org/Public/UNIDATA/Blocks.txt
_initBlocks('''
# Blocks-5.1.0.txt
# Date: 2008-03-20, 17:41:00 PDT [KW]
#
# Unicode Character Database
# Copyright (c) 1991-2008 Unicode, Inc.
# For terms of use, see http://www.unicode.org/terms_of_use.html
# For documentation, see UCD.html
#
# Note: The casing of block names is not normative.
# For example, "Basic Latin" and "BASIC LATIN" are equivalent.
#
# Format:
# Start Code..End Code; Block Name
#
# Note: When comparing block names, casing, whitespace, hyphens,
# and underbars are ignored.
# For example, "Latin Extended-A" and "latin extended a" are equivalent.
# For more information on the comparison of property values,
# see UCD.html.
#
# All code points not explicitly listed for Block
# have the value No_Block.
# Property: Block
#
# @missing: 0000..10FFFF; No_Block
0000..007F; Basic Latin
0080..00FF; Latin-1 Supplement
0100..017F; Latin Extended-A
0180..024F; Latin Extended-B
0250..02AF; IPA Extensions
02B0..02FF; Spacing Modifier Letters
0300..036F; Combining Diacritical Marks
0370..03FF; Greek and Coptic
0400..04FF; Cyrillic
0500..052F; Cyrillic Supplement
0530..058F; Armenian
0590..05FF; Hebrew
0600..06FF; Arabic
0700..074F; Syriac
0750..077F; Arabic Supplement
0780..07BF; Thaana
07C0..07FF; NKo
0900..097F; Devanagari
0980..09FF; Bengali
0A00..0A7F; Gurmukhi
0A80..0AFF; Gujarati
0B00..0B7F; Oriya
0B80..0BFF; Tamil
0C00..0C7F; Telugu
0C80..0CFF; Kannada
0D00..0D7F; Malayalam
0D80..0DFF; Sinhala
0E00..0E7F; Thai
0E80..0EFF; Lao
0F00..0FFF; Tibetan
1000..109F; Myanmar
10A0..10FF; Georgian
1100..11FF; Hangul Jamo
1200..137F; Ethiopic
1380..139F; Ethiopic Supplement
13A0..13FF; Cherokee
1400..167F; Unified Canadian Aboriginal Syllabics
1680..169F; Ogham
16A0..16FF; Runic
1700..171F; Tagalog
1720..173F; Hanunoo
1740..175F; Buhid
1760..177F; Tagbanwa
1780..17FF; Khmer
1800..18AF; Mongolian
1900..194F; Limbu
1950..197F; Tai Le
1980..19DF; New Tai Lue
19E0..19FF; Khmer Symbols
1A00..1A1F; Buginese
1B00..1B7F; Balinese
1B80..1BBF; Sundanese
1C00..1C4F; Lepcha
1C50..1C7F; Ol Chiki
1D00..1D7F; Phonetic Extensions
1D80..1DBF; Phonetic Extensions Supplement
1DC0..1DFF; Combining Diacritical Marks Supplement
1E00..1EFF; Latin Extended Additional
1F00..1FFF; Greek Extended
2000..206F; General Punctuation
2070..209F; Superscripts and Subscripts
20A0..20CF; Currency Symbols
20D0..20FF; Combining Diacritical Marks for Symbols
2100..214F; Letterlike Symbols
2150..218F; Number Forms
2190..21FF; Arrows
2200..22FF; Mathematical Operators
2300..23FF; Miscellaneous Technical
2400..243F; Control Pictures
2440..245F; Optical Character Recognition
2460..24FF; Enclosed Alphanumerics
2500..257F; Box Drawing
2580..259F; Block Elements
25A0..25FF; Geometric Shapes
2600..26FF; Miscellaneous Symbols
2700..27BF; Dingbats
27C0..27EF; Miscellaneous Mathematical Symbols-A
27F0..27FF; Supplemental Arrows-A
2800..28FF; Braille Patterns
2900..297F; Supplemental Arrows-B
2980..29FF; Miscellaneous Mathematical Symbols-B
2A00..2AFF; Supplemental Mathematical Operators
2B00..2BFF; Miscellaneous Symbols and Arrows
2C00..2C5F; Glagolitic
2C60..2C7F; Latin Extended-C
2C80..2CFF; Coptic
2D00..2D2F; Georgian Supplement
2D30..2D7F; Tifinagh
2D80..2DDF; Ethiopic Extended
2DE0..2DFF; Cyrillic Extended-A
2E00..2E7F; Supplemental Punctuation
2E80..2EFF; CJK Radicals Supplement
2F00..2FDF; Kangxi Radicals
2FF0..2FFF; Ideographic Description Characters
3000..303F; CJK Symbols and Punctuation
3040..309F; Hiragana
30A0..30FF; Katakana
3100..312F; Bopomofo
3130..318F; Hangul Compatibility Jamo
3190..319F; Kanbun
31A0..31BF; Bopomofo Extended
31C0..31EF; CJK Strokes
31F0..31FF; Katakana Phonetic Extensions
3200..32FF; Enclosed CJK Letters and Months
3300..33FF; CJK Compatibility
3400..4DBF; CJK Unified Ideographs Extension A
4DC0..4DFF; Yijing Hexagram Symbols
4E00..9FFF; CJK Unified Ideographs
A000..A48F; Yi Syllables
A490..A4CF; Yi Radicals
A500..A63F; Vai
A640..A69F; Cyrillic Extended-B
A700..A71F; Modifier Tone Letters
A720..A7FF; Latin Extended-D
A800..A82F; Syloti Nagri
A840..A87F; Phags-pa
A880..A8DF; Saurashtra
A900..A92F; Kayah Li
A930..A95F; Rejang
AA00..AA5F; Cham
AC00..D7AF; Hangul Syllables
D800..DB7F; High Surrogates
DB80..DBFF; High Private Use Surrogates
DC00..DFFF; Low Surrogates
E000..F8FF; Private Use Area
F900..FAFF; CJK Compatibility Ideographs
FB00..FB4F; Alphabetic Presentation Forms
FB50..FDFF; Arabic Presentation Forms-A
FE00..FE0F; Variation Selectors
FE10..FE1F; Vertical Forms
FE20..FE2F; Combining Half Marks
FE30..FE4F; CJK Compatibility Forms
FE50..FE6F; Small Form Variants
FE70..FEFF; Arabic Presentation Forms-B
FF00..FFEF; Halfwidth and Fullwidth Forms
FFF0..FFFF; Specials
10000..1007F; Linear B Syllabary
10080..100FF; Linear B Ideograms
10100..1013F; Aegean Numbers
10140..1018F; Ancient Greek Numbers
10190..101CF; Ancient Symbols
101D0..101FF; Phaistos Disc
10280..1029F; Lycian
102A0..102DF; Carian
10300..1032F; Old Italic
10330..1034F; Gothic
10380..1039F; Ugaritic
103A0..103DF; Old Persian
10400..1044F; Deseret
10450..1047F; Shavian
10480..104AF; Osmanya
10800..1083F; Cypriot Syllabary
10900..1091F; Phoenician
10920..1093F; Lydian
10A00..10A5F; Kharoshthi
12000..123FF; Cuneiform
12400..1247F; Cuneiform Numbers and Punctuation
1D000..1D0FF; Byzantine Musical Symbols
1D100..1D1FF; Musical Symbols
1D200..1D24F; Ancient Greek Musical Notation
1D300..1D35F; Tai Xuan Jing Symbols
1D360..1D37F; Counting Rod Numerals
1D400..1D7FF; Mathematical Alphanumeric Symbols
1F000..1F02F; Mahjong Tiles
1F030..1F09F; Domino Tiles
20000..2A6DF; CJK Unified Ideographs Extension B
2F800..2FA1F; CJK Compatibility Ideographs Supplement
E0000..E007F; Tags
E0100..E01EF; Variation Selectors Supplement
F0000..FFFFF; Supplementary Private Use Area-A
100000..10FFFF; Supplementary Private Use Area-B
# EOF
''')
###############################################################################
# See https://gist.github.com/anonymous/2204527 and
# https://stackoverflow.com/questions/9868792/
#
script_data = {
"scriptNames": [
"Common", "Latin", "Greek", "Cyrillic", "Armenian",
"Hebrew", "Arabic", "Syriac", "Thaana", "Devanagari",
"Bengali", "Gurmukhi", "Gujarati", "Oriya", "Tamil",
"Telugu", "Kannada", "Malayalam", "Sinhala", "Thai",
"Lao", "Tibetan", "Myanmar", "Georgian", "Hangul",
"Ethiopic", "Cherokee", "Canadian_Aboriginal","Ogham", "Runic",
"Khmer", "Mongolian", "Hiragana", "Katakana", "Bopomofo",
"Han", "Yi", "Old_Italic", "Gothic", "Deseret",
"Inherited", "Tagalog", "Hanunoo", "Buhid", "Tagbanwa",
"Limbu", "Tai_Le", "Linear_B", "Ugaritic", "Shavian",
"Osmanya", "Cypriot", "Braille", "Buginese", "Coptic",
"New_Tai_Lue", "Glagolitic", "Tifinagh", "Syloti_Nagri", "Old_Persian",
"Kharoshthi", "Balinese", "Cuneiform", "Phoenician", "Phags_Pa",
"Nko", "Sundanese", "Lepcha", "Ol_Chiki", "Vai",
"Saurashtra", "Kayah_Li", "Rejang", "Lycian", "Carian",
"Lydian", "Cham", "Tai_Tham", "Tai_Viet", "Avestan",
"Egyptian_Hieroglyphs","Samaritan", "Lisu", "Bamum", "Javanese",
"Meetei_Mayek","Imperial_Aramaic", "Old_South_Arabian",
"Inscriptional_Parthian", "Inscriptional_Pahlavi",
"Old_Turkic", "Kaithi", "Batak", "Brahmi", "Mandaic",
"Chakma", "Meroitic_Cursive", "Meroitic_Hieroglyphs","Miao", "Sharada",
"Sora_Sompeng","Takri"
],
"categoryAbbrs": [ # This is MISSING several categories (see unicodeCategories)
"Cc", "Zs", "Po", "Sc", "Ps", "Pe", "Sm", "Pd",
"Nd", "Sk", "Pc", "So", "Pi", "Cf", "No", "L",
"Pf", "Lm", "Mc", "Lo", "Zl", "Zp", "Nl", "Mn", "Me"
],
"idx": [ # Start, end, script, category
####### 0x0000...
(0x000,0x01f, 0, 0), (0x020,0x020, 0, 1), (0x021,0x023, 0, 2), (0x024,0x024, 0, 3),
(0x025,0x027, 0, 2), (0x028,0x028, 0, 4), (0x029,0x029, 0, 5), (0x02a,0x02a, 0, 2),
(0x02b,0x02b, 0, 6), (0x02c,0x02c, 0, 2), (0x02d,0x02d, 0, 7), (0x02e,0x02f, 0, 2),
(0x030,0x039, 0, 8), (0x03a,0x03b, 0, 2), (0x03c,0x03e, 0, 6), (0x03f,0x040, 0, 2),
(0x041,0x05a, 1,15), (0x05b,0x05b, 0, 4), (0x05c,0x05c, 0, 2), (0x05d,0x05d, 0, 5),
(0x05e,0x05e, 0, 9), (0x05f,0x05f, 0,10), (0x060,0x060, 0, 9), (0x061,0x07a, 1,15),
(0x07b,0x07b, 0, 4), (0x07c,0x07c, 0, 6), (0x07d,0x07d, 0, 5), (0x07e,0x07e, 0, 6),
(0x07f,0x09f, 0, 0), (0x0a0,0x0a0, 0, 1), (0x0a1,0x0a1, 0, 2), (0x0a2,0x0a5, 0, 3),
(0x0a6,0x0a6, 0,11), (0x0a7,0x0a7, 0, 2), (0x0a8,0x0a8, 0, 9), (0x0a9,0x0a9, 0,11),
(0x0aa,0x0aa, 1,19), (0x0ab,0x0ab, 0,12), (0x0ac,0x0ac, 0, 6), (0x0ad,0x0ad, 0,13),
(0x0ae,0x0ae, 0,11), (0x0af,0x0af, 0, 9), (0x0b0,0x0b0, 0,11), (0x0b1,0x0b1, 0, 6),
(0x0b2,0x0b3, 0,14), (0x0b4,0x0b4, 0, 9), (0x0b5,0x0b5, 0,15), (0x0b6,0x0b7, 0, 2),
(0x0b8,0x0b8, 0, 9), (0x0b9,0x0b9, 0,14), (0x0ba,0x0ba, 1,19), (0x0bb,0x0bb, 0,16),
(0x0bc,0x0be, 0,14), (0x0bf,0x0bf, 0, 2), (0x0c0,0x0d6, 1,15), (0x0d7,0x0d7, 0, 6),
(0x0d8,0x0f6, 1,15), (0x0f7,0x0f7, 0, 6), (0x0f8,0x1ba, 1,15), (0x1bb,0x1bb, 1,19),
(0x1bc,0x1bf, 1,15), (0x1c0,0x1c3, 1,19), (0x1c4,0x293, 1,15), (0x294,0x294, 1,19),
(0x295,0x2af, 1,15), (0x2b0,0x2b8, 1,17), (0x2b9,0x2c1, 0,17), (0x2c2,0x2c5, 0, 9),
(0x2c6,0x2d1, 0,17), (0x2d2,0x2df, 0, 9), (0x2e0,0x2e4, 1,17), (0x2e5,0x2e9, 0, 9),
(0x2ea,0x2eb,34, 9), (0x2ec,0x2ec, 0,17), (0x2ed,0x2ed, 0, 9), (0x2ee,0x2ee, 0,17),
(0x2ef,0x2ff, 0, 9), (0x300,0x36f,40,23), (0x370,0x373, 2,15), (0x374,0x374, 0,17),
(0x375,0x375, 2, 9), (0x376,0x377, 2,15), (0x37a,0x37a, 2,17), (0x37b,0x37d, 2,15),
(0x37e,0x37e, 0, 2), (0x384,0x384, 2, 9), (0x385,0x385, 0, 9), (0x386,0x386, 2,15),
(0x387,0x387, 0, 2), (0x388,0x38a, 2,15), (0x38c,0x38c, 2,15), (0x38e,0x3a1, 2,15),
(0x3a3,0x3e1, 2,15), (0x3e2,0x3ef,54,15), (0x3f0,0x3f5, 2,15), (0x3f6,0x3f6, 2, 6),
(0x3f7,0x3ff, 2,15), (0x400,0x481, 3,15), (0x482,0x482, 3,11), (0x483,0x484, 3,23),
####### 0x0400...
(0x485,0x486,40,23), (0x487,0x487, 3,23), (0x488,0x489, 3,24), (0x48a,0x527, 3,15),
(0x531,0x556, 4,15), (0x559,0x559, 4,17), (0x55a,0x55f, 4, 2), (0x561,0x587, 4,15),
(0x589,0x589, 0, 2), (0x58a,0x58a, 4, 7), (0x58f,0x58f, 4, 3), (0x591,0x5bd, 5,23),
(0x5be,0x5be, 5, 7), (0x5bf,0x5bf, 5,23), (0x5c0,0x5c0, 5, 2), (0x5c1,0x5c2, 5,23),
(0x5c3,0x5c3, 5, 2), (0x5c4,0x5c5, 5,23), (0x5c6,0x5c6, 5, 2), (0x5c7,0x5c7, 5,23),
(0x5d0,0x5ea, 5,19), (0x5f0,0x5f2, 5,19), (0x5f3,0x5f4, 5, 2), (0x600,0x604, 6,13),
(0x606,0x608, 6, 6), (0x609,0x60a, 6, 2), (0x60b,0x60b, 6, 3), (0x60c,0x60c, 0, 2),
(0x60d,0x60d, 6, 2), (0x60e,0x60f, 6,11), (0x610,0x61a, 6,23), (0x61b,0x61b, 0, 2),
(0x61e,0x61e, 6, 2), (0x61f,0x61f, 0, 2), (0x620,0x63f, 6,19), (0x640,0x640, 0,17),
(0x641,0x64a, 6,19), (0x64b,0x655,40,23), (0x656,0x65e, 6,23),
(0x65f,0x65f,40,23), (0x660,0x669, 0, 8), (0x66a,0x66d, 6, 2), (0x66e,0x66f, 6,19),
(0x670,0x670,40,23), (0x671,0x6d3, 6,19), (0x6d4,0x6d4, 6, 2), (0x6d5,0x6d5, 6,19),
(0x6d6,0x6dc, 6,23), (0x6dd,0x6dd, 0,13), (0x6de,0x6de, 6,11), (0x6df,0x6e4, 6,23),
(0x6e5,0x6e6, 6,17), (0x6e7,0x6e8, 6,23), (0x6e9,0x6e9, 6,11), (0x6ea,0x6ed, 6,23),
(0x6ee,0x6ef, 6,19), (0x6f0,0x6f9, 6, 8), (0x6fa,0x6fc, 6,19), (0x6fd,0x6fe, 6,11),
(0x6ff,0x6ff, 6,19), (0x700,0x70d, 7, 2), (0x70f,0x70f, 7,13), (0x710,0x710, 7,19),
(0x711,0x711, 7,23), (0x712,0x72f, 7,19), (0x730,0x74a, 7,23), (0x74d,0x74f, 7,19),
(0x750,0x77f, 6,19), (0x780,0x7a5, 8,19), (0x7a6,0x7b0, 8,23), (0x7b1,0x7b1, 8,19),
(0x7c0,0x7c9,65, 8), (0x7ca,0x7ea,65,19), (0x7eb,0x7f3,65,23),
(0x7f4,0x7f5,65,17), (0x7f6,0x7f6,65,11), (0x7f7,0x7f9,65, 2),
(0x7fa,0x7fa,65,17), (0x800,0x815,81,19), (0x816,0x819,81,23),
####### 0x0800...
(0x81a,0x81a,81,17), (0x81b,0x823,81,23), (0x824,0x824,81,17),
(0x825,0x827,81,23), (0x828,0x828,81,17), (0x829,0x82d,81,23),
(0x830,0x83e,81, 2), (0x840,0x858,94,19), (0x859,0x85b,94,23),
(0x85e,0x85e,94, 2), (0x8a0,0x8a0, 6,19), (0x8a2,0x8ac, 6,19), (0x8e4,0x8fe, 6,23),
(0x900,0x902, 9,23), (0x903,0x903, 9,18), (0x904,0x939, 9,19), (0x93a,0x93a, 9,23),
(0x93b,0x93b, 9,18), (0x93c,0x93c, 9,23), (0x93d,0x93d, 9,19), (0x93e,0x940, 9,18),
(0x941,0x948, 9,23), (0x949,0x94c, 9,18), (0x94d,0x94d, 9,23), (0x94e,0x94f, 9,18),
(0x950,0x950, 9,19), (0x951,0x952,40,23), (0x953,0x957, 9,23), (0x958,0x961, 9,19),
(0x962,0x963, 9,23), (0x964,0x965, 0, 2), (0x966,0x96f, 9, 8), (0x970,0x970, 9, 2),
(0x971,0x971, 9,17), (0x972,0x977, 9,19), (0x979,0x97f, 9,19), (0x981,0x981,10,23),
(0x982,0x983,10,18), (0x985,0x98c,10,19), (0x98f,0x990,10,19),
(0x993,0x9a8,10,19), (0x9aa,0x9b0,10,19), (0x9b2,0x9b2,10,19),
(0x9b6,0x9b9,10,19), (0x9bc,0x9bc,10,23), (0x9bd,0x9bd,10,19),
(0x9be,0x9c0,10,18), (0x9c1,0x9c4,10,23), (0x9c7,0x9c8,10,18),
(0x9cb,0x9cc,10,18), (0x9cd,0x9cd,10,23), (0x9ce,0x9ce,10,19),
(0x9d7,0x9d7,10,18), (0x9dc,0x9dd,10,19), (0x9df,0x9e1,10,19),
(0x9e2,0x9e3,10,23), (0x9e6,0x9ef,10, 8), (0x9f0,0x9f1,10,19),
(0x9f2,0x9f3,10, 3), (0x9f4,0x9f9,10,14), (0x9fa,0x9fa,10,11),
(0x9fb,0x9fb,10, 3), (0xa01,0xa02,11,23), (0xa03,0xa03,11,18),
(0xa05,0xa0a,11,19), (0xa0f,0xa10,11,19), (0xa13,0xa28,11,19),
(0xa2a,0xa30,11,19), (0xa32,0xa33,11,19), (0xa35,0xa36,11,19),
(0xa38,0xa39,11,19), (0xa3c,0xa3c,11,23), (0xa3e,0xa40,11,18),
(0xa41,0xa42,11,23), (0xa47,0xa48,11,23), (0xa4b,0xa4d,11,23),
(0xa51,0xa51,11,23), (0xa59,0xa5c,11,19), (0xa5e,0xa5e,11,19),
(0xa66,0xa6f,11, 8), (0xa70,0xa71,11,23), (0xa72,0xa74,11,19),
(0xa75,0xa75,11,23), (0xa81,0xa82,12,23), (0xa83,0xa83,12,18),
(0xa85,0xa8d,12,19), (0xa8f,0xa91,12,19), (0xa93,0xaa8,12,19),
(0xaaa,0xab0,12,19), (0xab2,0xab3,12,19), (0xab5,0xab9,12,19),
(0xabc,0xabc,12,23), (0xabd,0xabd,12,19), (0xabe,0xac0,12,18),
(0xac1,0xac5,12,23), (0xac7,0xac8,12,23), (0xac9,0xac9,12,18),
(0xacb,0xacc,12,18), (0xacd,0xacd,12,23), (0xad0,0xad0,12,19),
(0xae0,0xae1,12,19), (0xae2,0xae3,12,23), (0xae6,0xaef,12, 8),
(0xaf0,0xaf0,12, 2), (0xaf1,0xaf1,12, 3), (0xb01,0xb01,13,23),
(0xb02,0xb03,13,18), (0xb05,0xb0c,13,19), (0xb0f,0xb10,13,19),