1 | //===- llvm/Support/Unicode.cpp - Unicode character properties -*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file implements functions that allow querying certain properties of |
10 | // Unicode characters. |
11 | // |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #include "llvm/Support/Unicode.h" |
15 | #include "llvm/Support/ConvertUTF.h" |
16 | #include "llvm/Support/UnicodeCharRanges.h" |
17 | |
18 | namespace llvm { |
19 | namespace sys { |
20 | namespace unicode { |
21 | |
22 | /// Unicode code points of the categories L, M, N, P, S and Zs are considered |
23 | /// printable. |
24 | /// In addition, U+00AD SOFT HYPHEN is also considered printable, as |
25 | /// it's actually displayed on most terminals. \return true if the character is |
26 | /// considered printable. |
27 | bool isPrintable(int UCS) { |
28 | // https://unicode.org/Public/15.1.0/ucdxml/ |
29 | static const UnicodeCharRange PrintableRanges[] = { |
30 | {.Lower: 0x0020, .Upper: 0x007E}, {.Lower: 0x00A0, .Upper: 0x00AC}, {.Lower: 0x00AE, .Upper: 0x0377}, |
31 | {.Lower: 0x037A, .Upper: 0x037F}, {.Lower: 0x0384, .Upper: 0x038A}, {.Lower: 0x038C, .Upper: 0x038C}, |
32 | {.Lower: 0x038E, .Upper: 0x03A1}, {.Lower: 0x03A3, .Upper: 0x052F}, {.Lower: 0x0531, .Upper: 0x0556}, |
33 | {.Lower: 0x0559, .Upper: 0x058A}, {.Lower: 0x058D, .Upper: 0x058F}, {.Lower: 0x0591, .Upper: 0x05C7}, |
34 | {.Lower: 0x05D0, .Upper: 0x05EA}, {.Lower: 0x05EF, .Upper: 0x05F4}, {.Lower: 0x0606, .Upper: 0x061B}, |
35 | {.Lower: 0x061D, .Upper: 0x06DC}, {.Lower: 0x06DE, .Upper: 0x070D}, {.Lower: 0x0710, .Upper: 0x074A}, |
36 | {.Lower: 0x074D, .Upper: 0x07B1}, {.Lower: 0x07C0, .Upper: 0x07FA}, {.Lower: 0x07FD, .Upper: 0x082D}, |
37 | {.Lower: 0x0830, .Upper: 0x083E}, {.Lower: 0x0840, .Upper: 0x085B}, {.Lower: 0x085E, .Upper: 0x085E}, |
38 | {.Lower: 0x0860, .Upper: 0x086A}, {.Lower: 0x0870, .Upper: 0x088E}, {.Lower: 0x0898, .Upper: 0x08E1}, |
39 | {.Lower: 0x08E3, .Upper: 0x0983}, {.Lower: 0x0985, .Upper: 0x098C}, {.Lower: 0x098F, .Upper: 0x0990}, |
40 | {.Lower: 0x0993, .Upper: 0x09A8}, {.Lower: 0x09AA, .Upper: 0x09B0}, {.Lower: 0x09B2, .Upper: 0x09B2}, |
41 | {.Lower: 0x09B6, .Upper: 0x09B9}, {.Lower: 0x09BC, .Upper: 0x09C4}, {.Lower: 0x09C7, .Upper: 0x09C8}, |
42 | {.Lower: 0x09CB, .Upper: 0x09CE}, {.Lower: 0x09D7, .Upper: 0x09D7}, {.Lower: 0x09DC, .Upper: 0x09DD}, |
43 | {.Lower: 0x09DF, .Upper: 0x09E3}, {.Lower: 0x09E6, .Upper: 0x09FE}, {.Lower: 0x0A01, .Upper: 0x0A03}, |
44 | {.Lower: 0x0A05, .Upper: 0x0A0A}, {.Lower: 0x0A0F, .Upper: 0x0A10}, {.Lower: 0x0A13, .Upper: 0x0A28}, |
45 | {.Lower: 0x0A2A, .Upper: 0x0A30}, {.Lower: 0x0A32, .Upper: 0x0A33}, {.Lower: 0x0A35, .Upper: 0x0A36}, |
46 | {.Lower: 0x0A38, .Upper: 0x0A39}, {.Lower: 0x0A3C, .Upper: 0x0A3C}, {.Lower: 0x0A3E, .Upper: 0x0A42}, |
47 | {.Lower: 0x0A47, .Upper: 0x0A48}, {.Lower: 0x0A4B, .Upper: 0x0A4D}, {.Lower: 0x0A51, .Upper: 0x0A51}, |
48 | {.Lower: 0x0A59, .Upper: 0x0A5C}, {.Lower: 0x0A5E, .Upper: 0x0A5E}, {.Lower: 0x0A66, .Upper: 0x0A76}, |
49 | {.Lower: 0x0A81, .Upper: 0x0A83}, {.Lower: 0x0A85, .Upper: 0x0A8D}, {.Lower: 0x0A8F, .Upper: 0x0A91}, |
50 | {.Lower: 0x0A93, .Upper: 0x0AA8}, {.Lower: 0x0AAA, .Upper: 0x0AB0}, {.Lower: 0x0AB2, .Upper: 0x0AB3}, |
51 | {.Lower: 0x0AB5, .Upper: 0x0AB9}, {.Lower: 0x0ABC, .Upper: 0x0AC5}, {.Lower: 0x0AC7, .Upper: 0x0AC9}, |
52 | {.Lower: 0x0ACB, .Upper: 0x0ACD}, {.Lower: 0x0AD0, .Upper: 0x0AD0}, {.Lower: 0x0AE0, .Upper: 0x0AE3}, |
53 | {.Lower: 0x0AE6, .Upper: 0x0AF1}, {.Lower: 0x0AF9, .Upper: 0x0AFF}, {.Lower: 0x0B01, .Upper: 0x0B03}, |
54 | {.Lower: 0x0B05, .Upper: 0x0B0C}, {.Lower: 0x0B0F, .Upper: 0x0B10}, {.Lower: 0x0B13, .Upper: 0x0B28}, |
55 | {.Lower: 0x0B2A, .Upper: 0x0B30}, {.Lower: 0x0B32, .Upper: 0x0B33}, {.Lower: 0x0B35, .Upper: 0x0B39}, |
56 | {.Lower: 0x0B3C, .Upper: 0x0B44}, {.Lower: 0x0B47, .Upper: 0x0B48}, {.Lower: 0x0B4B, .Upper: 0x0B4D}, |
57 | {.Lower: 0x0B55, .Upper: 0x0B57}, {.Lower: 0x0B5C, .Upper: 0x0B5D}, {.Lower: 0x0B5F, .Upper: 0x0B63}, |
58 | {.Lower: 0x0B66, .Upper: 0x0B77}, {.Lower: 0x0B82, .Upper: 0x0B83}, {.Lower: 0x0B85, .Upper: 0x0B8A}, |
59 | {.Lower: 0x0B8E, .Upper: 0x0B90}, {.Lower: 0x0B92, .Upper: 0x0B95}, {.Lower: 0x0B99, .Upper: 0x0B9A}, |
60 | {.Lower: 0x0B9C, .Upper: 0x0B9C}, {.Lower: 0x0B9E, .Upper: 0x0B9F}, {.Lower: 0x0BA3, .Upper: 0x0BA4}, |
61 | {.Lower: 0x0BA8, .Upper: 0x0BAA}, {.Lower: 0x0BAE, .Upper: 0x0BB9}, {.Lower: 0x0BBE, .Upper: 0x0BC2}, |
62 | {.Lower: 0x0BC6, .Upper: 0x0BC8}, {.Lower: 0x0BCA, .Upper: 0x0BCD}, {.Lower: 0x0BD0, .Upper: 0x0BD0}, |
63 | {.Lower: 0x0BD7, .Upper: 0x0BD7}, {.Lower: 0x0BE6, .Upper: 0x0BFA}, {.Lower: 0x0C00, .Upper: 0x0C0C}, |
64 | {.Lower: 0x0C0E, .Upper: 0x0C10}, {.Lower: 0x0C12, .Upper: 0x0C28}, {.Lower: 0x0C2A, .Upper: 0x0C39}, |
65 | {.Lower: 0x0C3C, .Upper: 0x0C44}, {.Lower: 0x0C46, .Upper: 0x0C48}, {.Lower: 0x0C4A, .Upper: 0x0C4D}, |
66 | {.Lower: 0x0C55, .Upper: 0x0C56}, {.Lower: 0x0C58, .Upper: 0x0C5A}, {.Lower: 0x0C5D, .Upper: 0x0C5D}, |
67 | {.Lower: 0x0C60, .Upper: 0x0C63}, {.Lower: 0x0C66, .Upper: 0x0C6F}, {.Lower: 0x0C77, .Upper: 0x0C8C}, |
68 | {.Lower: 0x0C8E, .Upper: 0x0C90}, {.Lower: 0x0C92, .Upper: 0x0CA8}, {.Lower: 0x0CAA, .Upper: 0x0CB3}, |
69 | {.Lower: 0x0CB5, .Upper: 0x0CB9}, {.Lower: 0x0CBC, .Upper: 0x0CC4}, {.Lower: 0x0CC6, .Upper: 0x0CC8}, |
70 | {.Lower: 0x0CCA, .Upper: 0x0CCD}, {.Lower: 0x0CD5, .Upper: 0x0CD6}, {.Lower: 0x0CDD, .Upper: 0x0CDE}, |
71 | {.Lower: 0x0CE0, .Upper: 0x0CE3}, {.Lower: 0x0CE6, .Upper: 0x0CEF}, {.Lower: 0x0CF1, .Upper: 0x0CF3}, |
72 | {.Lower: 0x0D00, .Upper: 0x0D0C}, {.Lower: 0x0D0E, .Upper: 0x0D10}, {.Lower: 0x0D12, .Upper: 0x0D44}, |
73 | {.Lower: 0x0D46, .Upper: 0x0D48}, {.Lower: 0x0D4A, .Upper: 0x0D4F}, {.Lower: 0x0D54, .Upper: 0x0D63}, |
74 | {.Lower: 0x0D66, .Upper: 0x0D7F}, {.Lower: 0x0D81, .Upper: 0x0D83}, {.Lower: 0x0D85, .Upper: 0x0D96}, |
75 | {.Lower: 0x0D9A, .Upper: 0x0DB1}, {.Lower: 0x0DB3, .Upper: 0x0DBB}, {.Lower: 0x0DBD, .Upper: 0x0DBD}, |
76 | {.Lower: 0x0DC0, .Upper: 0x0DC6}, {.Lower: 0x0DCA, .Upper: 0x0DCA}, {.Lower: 0x0DCF, .Upper: 0x0DD4}, |
77 | {.Lower: 0x0DD6, .Upper: 0x0DD6}, {.Lower: 0x0DD8, .Upper: 0x0DDF}, {.Lower: 0x0DE6, .Upper: 0x0DEF}, |
78 | {.Lower: 0x0DF2, .Upper: 0x0DF4}, {.Lower: 0x0E01, .Upper: 0x0E3A}, {.Lower: 0x0E3F, .Upper: 0x0E5B}, |
79 | {.Lower: 0x0E81, .Upper: 0x0E82}, {.Lower: 0x0E84, .Upper: 0x0E84}, {.Lower: 0x0E86, .Upper: 0x0E8A}, |
80 | {.Lower: 0x0E8C, .Upper: 0x0EA3}, {.Lower: 0x0EA5, .Upper: 0x0EA5}, {.Lower: 0x0EA7, .Upper: 0x0EBD}, |
81 | {.Lower: 0x0EC0, .Upper: 0x0EC4}, {.Lower: 0x0EC6, .Upper: 0x0EC6}, {.Lower: 0x0EC8, .Upper: 0x0ECE}, |
82 | {.Lower: 0x0ED0, .Upper: 0x0ED9}, {.Lower: 0x0EDC, .Upper: 0x0EDF}, {.Lower: 0x0F00, .Upper: 0x0F47}, |
83 | {.Lower: 0x0F49, .Upper: 0x0F6C}, {.Lower: 0x0F71, .Upper: 0x0F97}, {.Lower: 0x0F99, .Upper: 0x0FBC}, |
84 | {.Lower: 0x0FBE, .Upper: 0x0FCC}, {.Lower: 0x0FCE, .Upper: 0x0FDA}, {.Lower: 0x1000, .Upper: 0x10C5}, |
85 | {.Lower: 0x10C7, .Upper: 0x10C7}, {.Lower: 0x10CD, .Upper: 0x10CD}, {.Lower: 0x10D0, .Upper: 0x1248}, |
86 | {.Lower: 0x124A, .Upper: 0x124D}, {.Lower: 0x1250, .Upper: 0x1256}, {.Lower: 0x1258, .Upper: 0x1258}, |
87 | {.Lower: 0x125A, .Upper: 0x125D}, {.Lower: 0x1260, .Upper: 0x1288}, {.Lower: 0x128A, .Upper: 0x128D}, |
88 | {.Lower: 0x1290, .Upper: 0x12B0}, {.Lower: 0x12B2, .Upper: 0x12B5}, {.Lower: 0x12B8, .Upper: 0x12BE}, |
89 | {.Lower: 0x12C0, .Upper: 0x12C0}, {.Lower: 0x12C2, .Upper: 0x12C5}, {.Lower: 0x12C8, .Upper: 0x12D6}, |
90 | {.Lower: 0x12D8, .Upper: 0x1310}, {.Lower: 0x1312, .Upper: 0x1315}, {.Lower: 0x1318, .Upper: 0x135A}, |
91 | {.Lower: 0x135D, .Upper: 0x137C}, {.Lower: 0x1380, .Upper: 0x1399}, {.Lower: 0x13A0, .Upper: 0x13F5}, |
92 | {.Lower: 0x13F8, .Upper: 0x13FD}, {.Lower: 0x1400, .Upper: 0x169C}, {.Lower: 0x16A0, .Upper: 0x16F8}, |
93 | {.Lower: 0x1700, .Upper: 0x1715}, {.Lower: 0x171F, .Upper: 0x1736}, {.Lower: 0x1740, .Upper: 0x1753}, |
94 | {.Lower: 0x1760, .Upper: 0x176C}, {.Lower: 0x176E, .Upper: 0x1770}, {.Lower: 0x1772, .Upper: 0x1773}, |
95 | {.Lower: 0x1780, .Upper: 0x17DD}, {.Lower: 0x17E0, .Upper: 0x17E9}, {.Lower: 0x17F0, .Upper: 0x17F9}, |
96 | {.Lower: 0x1800, .Upper: 0x180D}, {.Lower: 0x180F, .Upper: 0x1819}, {.Lower: 0x1820, .Upper: 0x1878}, |
97 | {.Lower: 0x1880, .Upper: 0x18AA}, {.Lower: 0x18B0, .Upper: 0x18F5}, {.Lower: 0x1900, .Upper: 0x191E}, |
98 | {.Lower: 0x1920, .Upper: 0x192B}, {.Lower: 0x1930, .Upper: 0x193B}, {.Lower: 0x1940, .Upper: 0x1940}, |
99 | {.Lower: 0x1944, .Upper: 0x196D}, {.Lower: 0x1970, .Upper: 0x1974}, {.Lower: 0x1980, .Upper: 0x19AB}, |
100 | {.Lower: 0x19B0, .Upper: 0x19C9}, {.Lower: 0x19D0, .Upper: 0x19DA}, {.Lower: 0x19DE, .Upper: 0x1A1B}, |
101 | {.Lower: 0x1A1E, .Upper: 0x1A5E}, {.Lower: 0x1A60, .Upper: 0x1A7C}, {.Lower: 0x1A7F, .Upper: 0x1A89}, |
102 | {.Lower: 0x1A90, .Upper: 0x1A99}, {.Lower: 0x1AA0, .Upper: 0x1AAD}, {.Lower: 0x1AB0, .Upper: 0x1ACE}, |
103 | {.Lower: 0x1B00, .Upper: 0x1B4C}, {.Lower: 0x1B50, .Upper: 0x1B7E}, {.Lower: 0x1B80, .Upper: 0x1BF3}, |
104 | {.Lower: 0x1BFC, .Upper: 0x1C37}, {.Lower: 0x1C3B, .Upper: 0x1C49}, {.Lower: 0x1C4D, .Upper: 0x1C88}, |
105 | {.Lower: 0x1C90, .Upper: 0x1CBA}, {.Lower: 0x1CBD, .Upper: 0x1CC7}, {.Lower: 0x1CD0, .Upper: 0x1CFA}, |
106 | {.Lower: 0x1D00, .Upper: 0x1F15}, {.Lower: 0x1F18, .Upper: 0x1F1D}, {.Lower: 0x1F20, .Upper: 0x1F45}, |
107 | {.Lower: 0x1F48, .Upper: 0x1F4D}, {.Lower: 0x1F50, .Upper: 0x1F57}, {.Lower: 0x1F59, .Upper: 0x1F59}, |
108 | {.Lower: 0x1F5B, .Upper: 0x1F5B}, {.Lower: 0x1F5D, .Upper: 0x1F5D}, {.Lower: 0x1F5F, .Upper: 0x1F7D}, |
109 | {.Lower: 0x1F80, .Upper: 0x1FB4}, {.Lower: 0x1FB6, .Upper: 0x1FC4}, {.Lower: 0x1FC6, .Upper: 0x1FD3}, |
110 | {.Lower: 0x1FD6, .Upper: 0x1FDB}, {.Lower: 0x1FDD, .Upper: 0x1FEF}, {.Lower: 0x1FF2, .Upper: 0x1FF4}, |
111 | {.Lower: 0x1FF6, .Upper: 0x1FFE}, {.Lower: 0x2000, .Upper: 0x200A}, {.Lower: 0x2010, .Upper: 0x2027}, |
112 | {.Lower: 0x202F, .Upper: 0x205F}, {.Lower: 0x2070, .Upper: 0x2071}, {.Lower: 0x2074, .Upper: 0x208E}, |
113 | {.Lower: 0x2090, .Upper: 0x209C}, {.Lower: 0x20A0, .Upper: 0x20C0}, {.Lower: 0x20D0, .Upper: 0x20F0}, |
114 | {.Lower: 0x2100, .Upper: 0x218B}, {.Lower: 0x2190, .Upper: 0x2426}, {.Lower: 0x2440, .Upper: 0x244A}, |
115 | {.Lower: 0x2460, .Upper: 0x2B73}, {.Lower: 0x2B76, .Upper: 0x2B95}, {.Lower: 0x2B97, .Upper: 0x2CF3}, |
116 | {.Lower: 0x2CF9, .Upper: 0x2D25}, {.Lower: 0x2D27, .Upper: 0x2D27}, {.Lower: 0x2D2D, .Upper: 0x2D2D}, |
117 | {.Lower: 0x2D30, .Upper: 0x2D67}, {.Lower: 0x2D6F, .Upper: 0x2D70}, {.Lower: 0x2D7F, .Upper: 0x2D96}, |
118 | {.Lower: 0x2DA0, .Upper: 0x2DA6}, {.Lower: 0x2DA8, .Upper: 0x2DAE}, {.Lower: 0x2DB0, .Upper: 0x2DB6}, |
119 | {.Lower: 0x2DB8, .Upper: 0x2DBE}, {.Lower: 0x2DC0, .Upper: 0x2DC6}, {.Lower: 0x2DC8, .Upper: 0x2DCE}, |
120 | {.Lower: 0x2DD0, .Upper: 0x2DD6}, {.Lower: 0x2DD8, .Upper: 0x2DDE}, {.Lower: 0x2DE0, .Upper: 0x2E5D}, |
121 | {.Lower: 0x2E80, .Upper: 0x2E99}, {.Lower: 0x2E9B, .Upper: 0x2EF3}, {.Lower: 0x2F00, .Upper: 0x2FD5}, |
122 | {.Lower: 0x2FF0, .Upper: 0x303F}, {.Lower: 0x3041, .Upper: 0x3096}, {.Lower: 0x3099, .Upper: 0x30FF}, |
123 | {.Lower: 0x3105, .Upper: 0x312F}, {.Lower: 0x3131, .Upper: 0x318E}, {.Lower: 0x3190, .Upper: 0x31E3}, |
124 | {.Lower: 0x31EF, .Upper: 0x321E}, {.Lower: 0x3220, .Upper: 0xA48C}, {.Lower: 0xA490, .Upper: 0xA4C6}, |
125 | {.Lower: 0xA4D0, .Upper: 0xA62B}, {.Lower: 0xA640, .Upper: 0xA6F7}, {.Lower: 0xA700, .Upper: 0xA7CA}, |
126 | {.Lower: 0xA7D0, .Upper: 0xA7D1}, {.Lower: 0xA7D3, .Upper: 0xA7D3}, {.Lower: 0xA7D5, .Upper: 0xA7D9}, |
127 | {.Lower: 0xA7F2, .Upper: 0xA82C}, {.Lower: 0xA830, .Upper: 0xA839}, {.Lower: 0xA840, .Upper: 0xA877}, |
128 | {.Lower: 0xA880, .Upper: 0xA8C5}, {.Lower: 0xA8CE, .Upper: 0xA8D9}, {.Lower: 0xA8E0, .Upper: 0xA953}, |
129 | {.Lower: 0xA95F, .Upper: 0xA97C}, {.Lower: 0xA980, .Upper: 0xA9CD}, {.Lower: 0xA9CF, .Upper: 0xA9D9}, |
130 | {.Lower: 0xA9DE, .Upper: 0xA9FE}, {.Lower: 0xAA00, .Upper: 0xAA36}, {.Lower: 0xAA40, .Upper: 0xAA4D}, |
131 | {.Lower: 0xAA50, .Upper: 0xAA59}, {.Lower: 0xAA5C, .Upper: 0xAAC2}, {.Lower: 0xAADB, .Upper: 0xAAF6}, |
132 | {.Lower: 0xAB01, .Upper: 0xAB06}, {.Lower: 0xAB09, .Upper: 0xAB0E}, {.Lower: 0xAB11, .Upper: 0xAB16}, |
133 | {.Lower: 0xAB20, .Upper: 0xAB26}, {.Lower: 0xAB28, .Upper: 0xAB2E}, {.Lower: 0xAB30, .Upper: 0xAB6B}, |
134 | {.Lower: 0xAB70, .Upper: 0xABED}, {.Lower: 0xABF0, .Upper: 0xABF9}, {.Lower: 0xAC00, .Upper: 0xD7A3}, |
135 | {.Lower: 0xD7B0, .Upper: 0xD7C6}, {.Lower: 0xD7CB, .Upper: 0xD7FB}, {.Lower: 0xF900, .Upper: 0xFA6D}, |
136 | {.Lower: 0xFA70, .Upper: 0xFAD9}, {.Lower: 0xFB00, .Upper: 0xFB06}, {.Lower: 0xFB13, .Upper: 0xFB17}, |
137 | {.Lower: 0xFB1D, .Upper: 0xFB36}, {.Lower: 0xFB38, .Upper: 0xFB3C}, {.Lower: 0xFB3E, .Upper: 0xFB3E}, |
138 | {.Lower: 0xFB40, .Upper: 0xFB41}, {.Lower: 0xFB43, .Upper: 0xFB44}, {.Lower: 0xFB46, .Upper: 0xFBC2}, |
139 | {.Lower: 0xFBD3, .Upper: 0xFD8F}, {.Lower: 0xFD92, .Upper: 0xFDC7}, {.Lower: 0xFDCF, .Upper: 0xFDCF}, |
140 | {.Lower: 0xFDF0, .Upper: 0xFE19}, {.Lower: 0xFE20, .Upper: 0xFE52}, {.Lower: 0xFE54, .Upper: 0xFE66}, |
141 | {.Lower: 0xFE68, .Upper: 0xFE6B}, {.Lower: 0xFE70, .Upper: 0xFE74}, {.Lower: 0xFE76, .Upper: 0xFEFC}, |
142 | {.Lower: 0xFF01, .Upper: 0xFFBE}, {.Lower: 0xFFC2, .Upper: 0xFFC7}, {.Lower: 0xFFCA, .Upper: 0xFFCF}, |
143 | {.Lower: 0xFFD2, .Upper: 0xFFD7}, {.Lower: 0xFFDA, .Upper: 0xFFDC}, {.Lower: 0xFFE0, .Upper: 0xFFE6}, |
144 | {.Lower: 0xFFE8, .Upper: 0xFFEE}, {.Lower: 0xFFFC, .Upper: 0xFFFD}, {.Lower: 0x10000, .Upper: 0x1000B}, |
145 | {.Lower: 0x1000D, .Upper: 0x10026}, {.Lower: 0x10028, .Upper: 0x1003A}, {.Lower: 0x1003C, .Upper: 0x1003D}, |
146 | {.Lower: 0x1003F, .Upper: 0x1004D}, {.Lower: 0x10050, .Upper: 0x1005D}, {.Lower: 0x10080, .Upper: 0x100FA}, |
147 | {.Lower: 0x10100, .Upper: 0x10102}, {.Lower: 0x10107, .Upper: 0x10133}, {.Lower: 0x10137, .Upper: 0x1018E}, |
148 | {.Lower: 0x10190, .Upper: 0x1019C}, {.Lower: 0x101A0, .Upper: 0x101A0}, {.Lower: 0x101D0, .Upper: 0x101FD}, |
149 | {.Lower: 0x10280, .Upper: 0x1029C}, {.Lower: 0x102A0, .Upper: 0x102D0}, {.Lower: 0x102E0, .Upper: 0x102FB}, |
150 | {.Lower: 0x10300, .Upper: 0x10323}, {.Lower: 0x1032D, .Upper: 0x1034A}, {.Lower: 0x10350, .Upper: 0x1037A}, |
151 | {.Lower: 0x10380, .Upper: 0x1039D}, {.Lower: 0x1039F, .Upper: 0x103C3}, {.Lower: 0x103C8, .Upper: 0x103D5}, |
152 | {.Lower: 0x10400, .Upper: 0x1049D}, {.Lower: 0x104A0, .Upper: 0x104A9}, {.Lower: 0x104B0, .Upper: 0x104D3}, |
153 | {.Lower: 0x104D8, .Upper: 0x104FB}, {.Lower: 0x10500, .Upper: 0x10527}, {.Lower: 0x10530, .Upper: 0x10563}, |
154 | {.Lower: 0x1056F, .Upper: 0x1057A}, {.Lower: 0x1057C, .Upper: 0x1058A}, {.Lower: 0x1058C, .Upper: 0x10592}, |
155 | {.Lower: 0x10594, .Upper: 0x10595}, {.Lower: 0x10597, .Upper: 0x105A1}, {.Lower: 0x105A3, .Upper: 0x105B1}, |
156 | {.Lower: 0x105B3, .Upper: 0x105B9}, {.Lower: 0x105BB, .Upper: 0x105BC}, {.Lower: 0x10600, .Upper: 0x10736}, |
157 | {.Lower: 0x10740, .Upper: 0x10755}, {.Lower: 0x10760, .Upper: 0x10767}, {.Lower: 0x10780, .Upper: 0x10785}, |
158 | {.Lower: 0x10787, .Upper: 0x107B0}, {.Lower: 0x107B2, .Upper: 0x107BA}, {.Lower: 0x10800, .Upper: 0x10805}, |
159 | {.Lower: 0x10808, .Upper: 0x10808}, {.Lower: 0x1080A, .Upper: 0x10835}, {.Lower: 0x10837, .Upper: 0x10838}, |
160 | {.Lower: 0x1083C, .Upper: 0x1083C}, {.Lower: 0x1083F, .Upper: 0x10855}, {.Lower: 0x10857, .Upper: 0x1089E}, |
161 | {.Lower: 0x108A7, .Upper: 0x108AF}, {.Lower: 0x108E0, .Upper: 0x108F2}, {.Lower: 0x108F4, .Upper: 0x108F5}, |
162 | {.Lower: 0x108FB, .Upper: 0x1091B}, {.Lower: 0x1091F, .Upper: 0x10939}, {.Lower: 0x1093F, .Upper: 0x1093F}, |
163 | {.Lower: 0x10980, .Upper: 0x109B7}, {.Lower: 0x109BC, .Upper: 0x109CF}, {.Lower: 0x109D2, .Upper: 0x10A03}, |
164 | {.Lower: 0x10A05, .Upper: 0x10A06}, {.Lower: 0x10A0C, .Upper: 0x10A13}, {.Lower: 0x10A15, .Upper: 0x10A17}, |
165 | {.Lower: 0x10A19, .Upper: 0x10A35}, {.Lower: 0x10A38, .Upper: 0x10A3A}, {.Lower: 0x10A3F, .Upper: 0x10A48}, |
166 | {.Lower: 0x10A50, .Upper: 0x10A58}, {.Lower: 0x10A60, .Upper: 0x10A9F}, {.Lower: 0x10AC0, .Upper: 0x10AE6}, |
167 | {.Lower: 0x10AEB, .Upper: 0x10AF6}, {.Lower: 0x10B00, .Upper: 0x10B35}, {.Lower: 0x10B39, .Upper: 0x10B55}, |
168 | {.Lower: 0x10B58, .Upper: 0x10B72}, {.Lower: 0x10B78, .Upper: 0x10B91}, {.Lower: 0x10B99, .Upper: 0x10B9C}, |
169 | {.Lower: 0x10BA9, .Upper: 0x10BAF}, {.Lower: 0x10C00, .Upper: 0x10C48}, {.Lower: 0x10C80, .Upper: 0x10CB2}, |
170 | {.Lower: 0x10CC0, .Upper: 0x10CF2}, {.Lower: 0x10CFA, .Upper: 0x10D27}, {.Lower: 0x10D30, .Upper: 0x10D39}, |
171 | {.Lower: 0x10E60, .Upper: 0x10E7E}, {.Lower: 0x10E80, .Upper: 0x10EA9}, {.Lower: 0x10EAB, .Upper: 0x10EAD}, |
172 | {.Lower: 0x10EB0, .Upper: 0x10EB1}, {.Lower: 0x10EFD, .Upper: 0x10F27}, {.Lower: 0x10F30, .Upper: 0x10F59}, |
173 | {.Lower: 0x10F70, .Upper: 0x10F89}, {.Lower: 0x10FB0, .Upper: 0x10FCB}, {.Lower: 0x10FE0, .Upper: 0x10FF6}, |
174 | {.Lower: 0x11000, .Upper: 0x1104D}, {.Lower: 0x11052, .Upper: 0x11075}, {.Lower: 0x1107F, .Upper: 0x110BC}, |
175 | {.Lower: 0x110BE, .Upper: 0x110C2}, {.Lower: 0x110D0, .Upper: 0x110E8}, {.Lower: 0x110F0, .Upper: 0x110F9}, |
176 | {.Lower: 0x11100, .Upper: 0x11134}, {.Lower: 0x11136, .Upper: 0x11147}, {.Lower: 0x11150, .Upper: 0x11176}, |
177 | {.Lower: 0x11180, .Upper: 0x111DF}, {.Lower: 0x111E1, .Upper: 0x111F4}, {.Lower: 0x11200, .Upper: 0x11211}, |
178 | {.Lower: 0x11213, .Upper: 0x11241}, {.Lower: 0x11280, .Upper: 0x11286}, {.Lower: 0x11288, .Upper: 0x11288}, |
179 | {.Lower: 0x1128A, .Upper: 0x1128D}, {.Lower: 0x1128F, .Upper: 0x1129D}, {.Lower: 0x1129F, .Upper: 0x112A9}, |
180 | {.Lower: 0x112B0, .Upper: 0x112EA}, {.Lower: 0x112F0, .Upper: 0x112F9}, {.Lower: 0x11300, .Upper: 0x11303}, |
181 | {.Lower: 0x11305, .Upper: 0x1130C}, {.Lower: 0x1130F, .Upper: 0x11310}, {.Lower: 0x11313, .Upper: 0x11328}, |
182 | {.Lower: 0x1132A, .Upper: 0x11330}, {.Lower: 0x11332, .Upper: 0x11333}, {.Lower: 0x11335, .Upper: 0x11339}, |
183 | {.Lower: 0x1133B, .Upper: 0x11344}, {.Lower: 0x11347, .Upper: 0x11348}, {.Lower: 0x1134B, .Upper: 0x1134D}, |
184 | {.Lower: 0x11350, .Upper: 0x11350}, {.Lower: 0x11357, .Upper: 0x11357}, {.Lower: 0x1135D, .Upper: 0x11363}, |
185 | {.Lower: 0x11366, .Upper: 0x1136C}, {.Lower: 0x11370, .Upper: 0x11374}, {.Lower: 0x11400, .Upper: 0x1145B}, |
186 | {.Lower: 0x1145D, .Upper: 0x11461}, {.Lower: 0x11480, .Upper: 0x114C7}, {.Lower: 0x114D0, .Upper: 0x114D9}, |
187 | {.Lower: 0x11580, .Upper: 0x115B5}, {.Lower: 0x115B8, .Upper: 0x115DD}, {.Lower: 0x11600, .Upper: 0x11644}, |
188 | {.Lower: 0x11650, .Upper: 0x11659}, {.Lower: 0x11660, .Upper: 0x1166C}, {.Lower: 0x11680, .Upper: 0x116B9}, |
189 | {.Lower: 0x116C0, .Upper: 0x116C9}, {.Lower: 0x11700, .Upper: 0x1171A}, {.Lower: 0x1171D, .Upper: 0x1172B}, |
190 | {.Lower: 0x11730, .Upper: 0x11746}, {.Lower: 0x11800, .Upper: 0x1183B}, {.Lower: 0x118A0, .Upper: 0x118F2}, |
191 | {.Lower: 0x118FF, .Upper: 0x11906}, {.Lower: 0x11909, .Upper: 0x11909}, {.Lower: 0x1190C, .Upper: 0x11913}, |
192 | {.Lower: 0x11915, .Upper: 0x11916}, {.Lower: 0x11918, .Upper: 0x11935}, {.Lower: 0x11937, .Upper: 0x11938}, |
193 | {.Lower: 0x1193B, .Upper: 0x11946}, {.Lower: 0x11950, .Upper: 0x11959}, {.Lower: 0x119A0, .Upper: 0x119A7}, |
194 | {.Lower: 0x119AA, .Upper: 0x119D7}, {.Lower: 0x119DA, .Upper: 0x119E4}, {.Lower: 0x11A00, .Upper: 0x11A47}, |
195 | {.Lower: 0x11A50, .Upper: 0x11AA2}, {.Lower: 0x11AB0, .Upper: 0x11AF8}, {.Lower: 0x11B00, .Upper: 0x11B09}, |
196 | {.Lower: 0x11C00, .Upper: 0x11C08}, {.Lower: 0x11C0A, .Upper: 0x11C36}, {.Lower: 0x11C38, .Upper: 0x11C45}, |
197 | {.Lower: 0x11C50, .Upper: 0x11C6C}, {.Lower: 0x11C70, .Upper: 0x11C8F}, {.Lower: 0x11C92, .Upper: 0x11CA7}, |
198 | {.Lower: 0x11CA9, .Upper: 0x11CB6}, {.Lower: 0x11D00, .Upper: 0x11D06}, {.Lower: 0x11D08, .Upper: 0x11D09}, |
199 | {.Lower: 0x11D0B, .Upper: 0x11D36}, {.Lower: 0x11D3A, .Upper: 0x11D3A}, {.Lower: 0x11D3C, .Upper: 0x11D3D}, |
200 | {.Lower: 0x11D3F, .Upper: 0x11D47}, {.Lower: 0x11D50, .Upper: 0x11D59}, {.Lower: 0x11D60, .Upper: 0x11D65}, |
201 | {.Lower: 0x11D67, .Upper: 0x11D68}, {.Lower: 0x11D6A, .Upper: 0x11D8E}, {.Lower: 0x11D90, .Upper: 0x11D91}, |
202 | {.Lower: 0x11D93, .Upper: 0x11D98}, {.Lower: 0x11DA0, .Upper: 0x11DA9}, {.Lower: 0x11EE0, .Upper: 0x11EF8}, |
203 | {.Lower: 0x11F00, .Upper: 0x11F10}, {.Lower: 0x11F12, .Upper: 0x11F3A}, {.Lower: 0x11F3E, .Upper: 0x11F59}, |
204 | {.Lower: 0x11FB0, .Upper: 0x11FB0}, {.Lower: 0x11FC0, .Upper: 0x11FF1}, {.Lower: 0x11FFF, .Upper: 0x12399}, |
205 | {.Lower: 0x12400, .Upper: 0x1246E}, {.Lower: 0x12470, .Upper: 0x12474}, {.Lower: 0x12480, .Upper: 0x12543}, |
206 | {.Lower: 0x12F90, .Upper: 0x12FF2}, {.Lower: 0x13000, .Upper: 0x1342F}, {.Lower: 0x13440, .Upper: 0x13455}, |
207 | {.Lower: 0x14400, .Upper: 0x14646}, {.Lower: 0x16800, .Upper: 0x16A38}, {.Lower: 0x16A40, .Upper: 0x16A5E}, |
208 | {.Lower: 0x16A60, .Upper: 0x16A69}, {.Lower: 0x16A6E, .Upper: 0x16ABE}, {.Lower: 0x16AC0, .Upper: 0x16AC9}, |
209 | {.Lower: 0x16AD0, .Upper: 0x16AED}, {.Lower: 0x16AF0, .Upper: 0x16AF5}, {.Lower: 0x16B00, .Upper: 0x16B45}, |
210 | {.Lower: 0x16B50, .Upper: 0x16B59}, {.Lower: 0x16B5B, .Upper: 0x16B61}, {.Lower: 0x16B63, .Upper: 0x16B77}, |
211 | {.Lower: 0x16B7D, .Upper: 0x16B8F}, {.Lower: 0x16E40, .Upper: 0x16E9A}, {.Lower: 0x16F00, .Upper: 0x16F4A}, |
212 | {.Lower: 0x16F4F, .Upper: 0x16F87}, {.Lower: 0x16F8F, .Upper: 0x16F9F}, {.Lower: 0x16FE0, .Upper: 0x16FE4}, |
213 | {.Lower: 0x16FF0, .Upper: 0x16FF1}, {.Lower: 0x17000, .Upper: 0x187F7}, {.Lower: 0x18800, .Upper: 0x18CD5}, |
214 | {.Lower: 0x18D00, .Upper: 0x18D08}, {.Lower: 0x1AFF0, .Upper: 0x1AFF3}, {.Lower: 0x1AFF5, .Upper: 0x1AFFB}, |
215 | {.Lower: 0x1AFFD, .Upper: 0x1AFFE}, {.Lower: 0x1B000, .Upper: 0x1B122}, {.Lower: 0x1B132, .Upper: 0x1B132}, |
216 | {.Lower: 0x1B150, .Upper: 0x1B152}, {.Lower: 0x1B155, .Upper: 0x1B155}, {.Lower: 0x1B164, .Upper: 0x1B167}, |
217 | {.Lower: 0x1B170, .Upper: 0x1B2FB}, {.Lower: 0x1BC00, .Upper: 0x1BC6A}, {.Lower: 0x1BC70, .Upper: 0x1BC7C}, |
218 | {.Lower: 0x1BC80, .Upper: 0x1BC88}, {.Lower: 0x1BC90, .Upper: 0x1BC99}, {.Lower: 0x1BC9C, .Upper: 0x1BC9F}, |
219 | {.Lower: 0x1CF00, .Upper: 0x1CF2D}, {.Lower: 0x1CF30, .Upper: 0x1CF46}, {.Lower: 0x1CF50, .Upper: 0x1CFC3}, |
220 | {.Lower: 0x1D000, .Upper: 0x1D0F5}, {.Lower: 0x1D100, .Upper: 0x1D126}, {.Lower: 0x1D129, .Upper: 0x1D172}, |
221 | {.Lower: 0x1D17B, .Upper: 0x1D1EA}, {.Lower: 0x1D200, .Upper: 0x1D245}, {.Lower: 0x1D2C0, .Upper: 0x1D2D3}, |
222 | {.Lower: 0x1D2E0, .Upper: 0x1D2F3}, {.Lower: 0x1D300, .Upper: 0x1D356}, {.Lower: 0x1D360, .Upper: 0x1D378}, |
223 | {.Lower: 0x1D400, .Upper: 0x1D454}, {.Lower: 0x1D456, .Upper: 0x1D49C}, {.Lower: 0x1D49E, .Upper: 0x1D49F}, |
224 | {.Lower: 0x1D4A2, .Upper: 0x1D4A2}, {.Lower: 0x1D4A5, .Upper: 0x1D4A6}, {.Lower: 0x1D4A9, .Upper: 0x1D4AC}, |
225 | {.Lower: 0x1D4AE, .Upper: 0x1D4B9}, {.Lower: 0x1D4BB, .Upper: 0x1D4BB}, {.Lower: 0x1D4BD, .Upper: 0x1D4C3}, |
226 | {.Lower: 0x1D4C5, .Upper: 0x1D505}, {.Lower: 0x1D507, .Upper: 0x1D50A}, {.Lower: 0x1D50D, .Upper: 0x1D514}, |
227 | {.Lower: 0x1D516, .Upper: 0x1D51C}, {.Lower: 0x1D51E, .Upper: 0x1D539}, {.Lower: 0x1D53B, .Upper: 0x1D53E}, |
228 | {.Lower: 0x1D540, .Upper: 0x1D544}, {.Lower: 0x1D546, .Upper: 0x1D546}, {.Lower: 0x1D54A, .Upper: 0x1D550}, |
229 | {.Lower: 0x1D552, .Upper: 0x1D6A5}, {.Lower: 0x1D6A8, .Upper: 0x1D7CB}, {.Lower: 0x1D7CE, .Upper: 0x1DA8B}, |
230 | {.Lower: 0x1DA9B, .Upper: 0x1DA9F}, {.Lower: 0x1DAA1, .Upper: 0x1DAAF}, {.Lower: 0x1DF00, .Upper: 0x1DF1E}, |
231 | {.Lower: 0x1DF25, .Upper: 0x1DF2A}, {.Lower: 0x1E000, .Upper: 0x1E006}, {.Lower: 0x1E008, .Upper: 0x1E018}, |
232 | {.Lower: 0x1E01B, .Upper: 0x1E021}, {.Lower: 0x1E023, .Upper: 0x1E024}, {.Lower: 0x1E026, .Upper: 0x1E02A}, |
233 | {.Lower: 0x1E030, .Upper: 0x1E06D}, {.Lower: 0x1E08F, .Upper: 0x1E08F}, {.Lower: 0x1E100, .Upper: 0x1E12C}, |
234 | {.Lower: 0x1E130, .Upper: 0x1E13D}, {.Lower: 0x1E140, .Upper: 0x1E149}, {.Lower: 0x1E14E, .Upper: 0x1E14F}, |
235 | {.Lower: 0x1E290, .Upper: 0x1E2AE}, {.Lower: 0x1E2C0, .Upper: 0x1E2F9}, {.Lower: 0x1E2FF, .Upper: 0x1E2FF}, |
236 | {.Lower: 0x1E4D0, .Upper: 0x1E4F9}, {.Lower: 0x1E7E0, .Upper: 0x1E7E6}, {.Lower: 0x1E7E8, .Upper: 0x1E7EB}, |
237 | {.Lower: 0x1E7ED, .Upper: 0x1E7EE}, {.Lower: 0x1E7F0, .Upper: 0x1E7FE}, {.Lower: 0x1E800, .Upper: 0x1E8C4}, |
238 | {.Lower: 0x1E8C7, .Upper: 0x1E8D6}, {.Lower: 0x1E900, .Upper: 0x1E94B}, {.Lower: 0x1E950, .Upper: 0x1E959}, |
239 | {.Lower: 0x1E95E, .Upper: 0x1E95F}, {.Lower: 0x1EC71, .Upper: 0x1ECB4}, {.Lower: 0x1ED01, .Upper: 0x1ED3D}, |
240 | {.Lower: 0x1EE00, .Upper: 0x1EE03}, {.Lower: 0x1EE05, .Upper: 0x1EE1F}, {.Lower: 0x1EE21, .Upper: 0x1EE22}, |
241 | {.Lower: 0x1EE24, .Upper: 0x1EE24}, {.Lower: 0x1EE27, .Upper: 0x1EE27}, {.Lower: 0x1EE29, .Upper: 0x1EE32}, |
242 | {.Lower: 0x1EE34, .Upper: 0x1EE37}, {.Lower: 0x1EE39, .Upper: 0x1EE39}, {.Lower: 0x1EE3B, .Upper: 0x1EE3B}, |
243 | {.Lower: 0x1EE42, .Upper: 0x1EE42}, {.Lower: 0x1EE47, .Upper: 0x1EE47}, {.Lower: 0x1EE49, .Upper: 0x1EE49}, |
244 | {.Lower: 0x1EE4B, .Upper: 0x1EE4B}, {.Lower: 0x1EE4D, .Upper: 0x1EE4F}, {.Lower: 0x1EE51, .Upper: 0x1EE52}, |
245 | {.Lower: 0x1EE54, .Upper: 0x1EE54}, {.Lower: 0x1EE57, .Upper: 0x1EE57}, {.Lower: 0x1EE59, .Upper: 0x1EE59}, |
246 | {.Lower: 0x1EE5B, .Upper: 0x1EE5B}, {.Lower: 0x1EE5D, .Upper: 0x1EE5D}, {.Lower: 0x1EE5F, .Upper: 0x1EE5F}, |
247 | {.Lower: 0x1EE61, .Upper: 0x1EE62}, {.Lower: 0x1EE64, .Upper: 0x1EE64}, {.Lower: 0x1EE67, .Upper: 0x1EE6A}, |
248 | {.Lower: 0x1EE6C, .Upper: 0x1EE72}, {.Lower: 0x1EE74, .Upper: 0x1EE77}, {.Lower: 0x1EE79, .Upper: 0x1EE7C}, |
249 | {.Lower: 0x1EE7E, .Upper: 0x1EE7E}, {.Lower: 0x1EE80, .Upper: 0x1EE89}, {.Lower: 0x1EE8B, .Upper: 0x1EE9B}, |
250 | {.Lower: 0x1EEA1, .Upper: 0x1EEA3}, {.Lower: 0x1EEA5, .Upper: 0x1EEA9}, {.Lower: 0x1EEAB, .Upper: 0x1EEBB}, |
251 | {.Lower: 0x1EEF0, .Upper: 0x1EEF1}, {.Lower: 0x1F000, .Upper: 0x1F02B}, {.Lower: 0x1F030, .Upper: 0x1F093}, |
252 | {.Lower: 0x1F0A0, .Upper: 0x1F0AE}, {.Lower: 0x1F0B1, .Upper: 0x1F0BF}, {.Lower: 0x1F0C1, .Upper: 0x1F0CF}, |
253 | {.Lower: 0x1F0D1, .Upper: 0x1F0F5}, {.Lower: 0x1F100, .Upper: 0x1F1AD}, {.Lower: 0x1F1E6, .Upper: 0x1F202}, |
254 | {.Lower: 0x1F210, .Upper: 0x1F23B}, {.Lower: 0x1F240, .Upper: 0x1F248}, {.Lower: 0x1F250, .Upper: 0x1F251}, |
255 | {.Lower: 0x1F260, .Upper: 0x1F265}, {.Lower: 0x1F300, .Upper: 0x1F6D7}, {.Lower: 0x1F6DC, .Upper: 0x1F6EC}, |
256 | {.Lower: 0x1F6F0, .Upper: 0x1F6FC}, {.Lower: 0x1F700, .Upper: 0x1F776}, {.Lower: 0x1F77B, .Upper: 0x1F7D9}, |
257 | {.Lower: 0x1F7E0, .Upper: 0x1F7EB}, {.Lower: 0x1F7F0, .Upper: 0x1F7F0}, {.Lower: 0x1F800, .Upper: 0x1F80B}, |
258 | {.Lower: 0x1F810, .Upper: 0x1F847}, {.Lower: 0x1F850, .Upper: 0x1F859}, {.Lower: 0x1F860, .Upper: 0x1F887}, |
259 | {.Lower: 0x1F890, .Upper: 0x1F8AD}, {.Lower: 0x1F8B0, .Upper: 0x1F8B1}, {.Lower: 0x1F900, .Upper: 0x1FA53}, |
260 | {.Lower: 0x1FA60, .Upper: 0x1FA6D}, {.Lower: 0x1FA70, .Upper: 0x1FA7C}, {.Lower: 0x1FA80, .Upper: 0x1FA88}, |
261 | {.Lower: 0x1FA90, .Upper: 0x1FABD}, {.Lower: 0x1FABF, .Upper: 0x1FAC5}, {.Lower: 0x1FACE, .Upper: 0x1FADB}, |
262 | {.Lower: 0x1FAE0, .Upper: 0x1FAE8}, {.Lower: 0x1FAF0, .Upper: 0x1FAF8}, {.Lower: 0x1FB00, .Upper: 0x1FB92}, |
263 | {.Lower: 0x1FB94, .Upper: 0x1FBCA}, {.Lower: 0x1FBF0, .Upper: 0x1FBF9}, {.Lower: 0x20000, .Upper: 0x2A6DF}, |
264 | {.Lower: 0x2A700, .Upper: 0x2B739}, {.Lower: 0x2B740, .Upper: 0x2B81D}, {.Lower: 0x2B820, .Upper: 0x2CEA1}, |
265 | {.Lower: 0x2CEB0, .Upper: 0x2EBE0}, {.Lower: 0x2EBF0, .Upper: 0x2EE5D}, {.Lower: 0x2F800, .Upper: 0x2FA1D}, |
266 | {.Lower: 0x30000, .Upper: 0x3134A}, {.Lower: 0x31350, .Upper: 0x323AF}, {.Lower: 0xE0100, .Upper: 0xE01EF}, |
267 | }; |
268 | |
269 | static const UnicodeCharSet Printables(PrintableRanges); |
270 | // Clang special cases 0x00AD (SOFT HYPHEN) which is rendered as an actual |
271 | // hyphen in most terminals. |
272 | return UCS == 0x00AD || Printables.contains(C: UCS); |
273 | } |
274 | |
275 | /// Unicode code points of the Cf category are considered |
276 | /// formatting characters. |
277 | bool isFormatting(int UCS) { |
278 | |
279 | // https://unicode.org/Public/15.1.0/ucdxml/ |
280 | static const UnicodeCharRange Cf[] = { |
281 | {.Lower: 0x00AD, .Upper: 0x00AD}, {.Lower: 0x0600, .Upper: 0x0605}, {.Lower: 0x061C, .Upper: 0x061C}, |
282 | {.Lower: 0x06DD, .Upper: 0x06DD}, {.Lower: 0x070F, .Upper: 0x070F}, {.Lower: 0x0890, .Upper: 0x0891}, |
283 | {.Lower: 0x08E2, .Upper: 0x08E2}, {.Lower: 0x180E, .Upper: 0x180E}, {.Lower: 0x200B, .Upper: 0x200F}, |
284 | {.Lower: 0x202A, .Upper: 0x202E}, {.Lower: 0x2060, .Upper: 0x2064}, {.Lower: 0x2066, .Upper: 0x206F}, |
285 | {.Lower: 0xFEFF, .Upper: 0xFEFF}, {.Lower: 0xFFF9, .Upper: 0xFFFB}, {.Lower: 0x110BD, .Upper: 0x110BD}, |
286 | {.Lower: 0x110CD, .Upper: 0x110CD}, {.Lower: 0x13430, .Upper: 0x1343F}, {.Lower: 0x1BCA0, .Upper: 0x1BCA3}, |
287 | {.Lower: 0x1D173, .Upper: 0x1D17A}, {.Lower: 0xE0001, .Upper: 0xE0001}, {.Lower: 0xE0020, .Upper: 0xE007F}}; |
288 | |
289 | static const UnicodeCharSet Format(Cf); |
290 | return Format.contains(C: UCS); |
291 | } |
292 | |
293 | /// Gets the number of positions a character is likely to occupy when output |
294 | /// on a terminal ("character width"). This depends on the implementation of the |
295 | /// terminal, and there's no standard definition of character width. |
296 | /// The implementation defines it in a way that is expected to be compatible |
297 | /// with a generic Unicode-capable terminal. |
298 | /// \return Character width: |
299 | /// * ErrorNonPrintableCharacter (-1) for non-printable characters (as |
300 | /// identified by isPrintable); |
301 | /// * 0 for non-spacing and enclosing combining marks; |
302 | /// * 2 for CJK characters excluding halfwidth forms; |
303 | /// * 1 for all remaining characters. |
304 | static inline int charWidth(int UCS) { |
305 | if (!isPrintable(UCS)) |
306 | return ErrorNonPrintableCharacter; |
307 | |
308 | // Sorted list of non-spacing and enclosing combining mark intervals as |
309 | // defined in "3.6 Combination" of |
310 | // https://www.unicode.org/versions/Unicode15.0.0/UnicodeStandard-15.0.pdf |
311 | static const UnicodeCharRange CombiningCharacterRanges[] = { |
312 | {.Lower: 0x0300, .Upper: 0x036F}, {.Lower: 0x0483, .Upper: 0x0489}, {.Lower: 0x0591, .Upper: 0x05BD}, |
313 | {.Lower: 0x05BF, .Upper: 0x05BF}, {.Lower: 0x05C1, .Upper: 0x05C2}, {.Lower: 0x05C4, .Upper: 0x05C5}, |
314 | {.Lower: 0x05C7, .Upper: 0x05C7}, {.Lower: 0x0610, .Upper: 0x061A}, {.Lower: 0x064B, .Upper: 0x065F}, |
315 | {.Lower: 0x0670, .Upper: 0x0670}, {.Lower: 0x06D6, .Upper: 0x06DC}, {.Lower: 0x06DF, .Upper: 0x06E4}, |
316 | {.Lower: 0x06E7, .Upper: 0x06E8}, {.Lower: 0x06EA, .Upper: 0x06ED}, {.Lower: 0x0711, .Upper: 0x0711}, |
317 | {.Lower: 0x0730, .Upper: 0x074A}, {.Lower: 0x07A6, .Upper: 0x07B0}, {.Lower: 0x07EB, .Upper: 0x07F3}, |
318 | {.Lower: 0x07FD, .Upper: 0x07FD}, {.Lower: 0x0816, .Upper: 0x0819}, {.Lower: 0x081B, .Upper: 0x0823}, |
319 | {.Lower: 0x0825, .Upper: 0x0827}, {.Lower: 0x0829, .Upper: 0x082D}, {.Lower: 0x0859, .Upper: 0x085B}, |
320 | {.Lower: 0x0898, .Upper: 0x089F}, {.Lower: 0x08CA, .Upper: 0x08E1}, {.Lower: 0x08E3, .Upper: 0x0902}, |
321 | {.Lower: 0x093A, .Upper: 0x093A}, {.Lower: 0x093C, .Upper: 0x093C}, {.Lower: 0x0941, .Upper: 0x0948}, |
322 | {.Lower: 0x094D, .Upper: 0x094D}, {.Lower: 0x0951, .Upper: 0x0957}, {.Lower: 0x0962, .Upper: 0x0963}, |
323 | {.Lower: 0x0981, .Upper: 0x0981}, {.Lower: 0x09BC, .Upper: 0x09BC}, {.Lower: 0x09C1, .Upper: 0x09C4}, |
324 | {.Lower: 0x09CD, .Upper: 0x09CD}, {.Lower: 0x09E2, .Upper: 0x09E3}, {.Lower: 0x09FE, .Upper: 0x09FE}, |
325 | {.Lower: 0x0A01, .Upper: 0x0A02}, {.Lower: 0x0A3C, .Upper: 0x0A3C}, {.Lower: 0x0A41, .Upper: 0x0A42}, |
326 | {.Lower: 0x0A47, .Upper: 0x0A48}, {.Lower: 0x0A4B, .Upper: 0x0A4D}, {.Lower: 0x0A51, .Upper: 0x0A51}, |
327 | {.Lower: 0x0A70, .Upper: 0x0A71}, {.Lower: 0x0A75, .Upper: 0x0A75}, {.Lower: 0x0A81, .Upper: 0x0A82}, |
328 | {.Lower: 0x0ABC, .Upper: 0x0ABC}, {.Lower: 0x0AC1, .Upper: 0x0AC5}, {.Lower: 0x0AC7, .Upper: 0x0AC8}, |
329 | {.Lower: 0x0ACD, .Upper: 0x0ACD}, {.Lower: 0x0AE2, .Upper: 0x0AE3}, {.Lower: 0x0AFA, .Upper: 0x0AFF}, |
330 | {.Lower: 0x0B01, .Upper: 0x0B01}, {.Lower: 0x0B3C, .Upper: 0x0B3C}, {.Lower: 0x0B3F, .Upper: 0x0B3F}, |
331 | {.Lower: 0x0B41, .Upper: 0x0B44}, {.Lower: 0x0B4D, .Upper: 0x0B4D}, {.Lower: 0x0B55, .Upper: 0x0B56}, |
332 | {.Lower: 0x0B62, .Upper: 0x0B63}, {.Lower: 0x0B82, .Upper: 0x0B82}, {.Lower: 0x0BC0, .Upper: 0x0BC0}, |
333 | {.Lower: 0x0BCD, .Upper: 0x0BCD}, {.Lower: 0x0C00, .Upper: 0x0C00}, {.Lower: 0x0C04, .Upper: 0x0C04}, |
334 | {.Lower: 0x0C3C, .Upper: 0x0C3C}, {.Lower: 0x0C3E, .Upper: 0x0C40}, {.Lower: 0x0C46, .Upper: 0x0C48}, |
335 | {.Lower: 0x0C4A, .Upper: 0x0C4D}, {.Lower: 0x0C55, .Upper: 0x0C56}, {.Lower: 0x0C62, .Upper: 0x0C63}, |
336 | {.Lower: 0x0C81, .Upper: 0x0C81}, {.Lower: 0x0CBC, .Upper: 0x0CBC}, {.Lower: 0x0CBF, .Upper: 0x0CBF}, |
337 | {.Lower: 0x0CC6, .Upper: 0x0CC6}, {.Lower: 0x0CCC, .Upper: 0x0CCD}, {.Lower: 0x0CE2, .Upper: 0x0CE3}, |
338 | {.Lower: 0x0D00, .Upper: 0x0D01}, {.Lower: 0x0D3B, .Upper: 0x0D3C}, {.Lower: 0x0D41, .Upper: 0x0D44}, |
339 | {.Lower: 0x0D4D, .Upper: 0x0D4D}, {.Lower: 0x0D62, .Upper: 0x0D63}, {.Lower: 0x0D81, .Upper: 0x0D81}, |
340 | {.Lower: 0x0DCA, .Upper: 0x0DCA}, {.Lower: 0x0DD2, .Upper: 0x0DD4}, {.Lower: 0x0DD6, .Upper: 0x0DD6}, |
341 | {.Lower: 0x0E31, .Upper: 0x0E31}, {.Lower: 0x0E34, .Upper: 0x0E3A}, {.Lower: 0x0E47, .Upper: 0x0E4E}, |
342 | {.Lower: 0x0EB1, .Upper: 0x0EB1}, {.Lower: 0x0EB4, .Upper: 0x0EBC}, {.Lower: 0x0EC8, .Upper: 0x0ECE}, |
343 | {.Lower: 0x0F18, .Upper: 0x0F19}, {.Lower: 0x0F35, .Upper: 0x0F35}, {.Lower: 0x0F37, .Upper: 0x0F37}, |
344 | {.Lower: 0x0F39, .Upper: 0x0F39}, {.Lower: 0x0F71, .Upper: 0x0F7E}, {.Lower: 0x0F80, .Upper: 0x0F84}, |
345 | {.Lower: 0x0F86, .Upper: 0x0F87}, {.Lower: 0x0F8D, .Upper: 0x0F97}, {.Lower: 0x0F99, .Upper: 0x0FBC}, |
346 | {.Lower: 0x0FC6, .Upper: 0x0FC6}, {.Lower: 0x102D, .Upper: 0x1030}, {.Lower: 0x1032, .Upper: 0x1037}, |
347 | {.Lower: 0x1039, .Upper: 0x103A}, {.Lower: 0x103D, .Upper: 0x103E}, {.Lower: 0x1058, .Upper: 0x1059}, |
348 | {.Lower: 0x105E, .Upper: 0x1060}, {.Lower: 0x1071, .Upper: 0x1074}, {.Lower: 0x1082, .Upper: 0x1082}, |
349 | {.Lower: 0x1085, .Upper: 0x1086}, {.Lower: 0x108D, .Upper: 0x108D}, {.Lower: 0x109D, .Upper: 0x109D}, |
350 | {.Lower: 0x135D, .Upper: 0x135F}, {.Lower: 0x1712, .Upper: 0x1714}, {.Lower: 0x1732, .Upper: 0x1733}, |
351 | {.Lower: 0x1752, .Upper: 0x1753}, {.Lower: 0x1772, .Upper: 0x1773}, {.Lower: 0x17B4, .Upper: 0x17B5}, |
352 | {.Lower: 0x17B7, .Upper: 0x17BD}, {.Lower: 0x17C6, .Upper: 0x17C6}, {.Lower: 0x17C9, .Upper: 0x17D3}, |
353 | {.Lower: 0x17DD, .Upper: 0x17DD}, {.Lower: 0x180B, .Upper: 0x180D}, {.Lower: 0x180F, .Upper: 0x180F}, |
354 | {.Lower: 0x1885, .Upper: 0x1886}, {.Lower: 0x18A9, .Upper: 0x18A9}, {.Lower: 0x1920, .Upper: 0x1922}, |
355 | {.Lower: 0x1927, .Upper: 0x1928}, {.Lower: 0x1932, .Upper: 0x1932}, {.Lower: 0x1939, .Upper: 0x193B}, |
356 | {.Lower: 0x1A17, .Upper: 0x1A18}, {.Lower: 0x1A1B, .Upper: 0x1A1B}, {.Lower: 0x1A56, .Upper: 0x1A56}, |
357 | {.Lower: 0x1A58, .Upper: 0x1A5E}, {.Lower: 0x1A60, .Upper: 0x1A60}, {.Lower: 0x1A62, .Upper: 0x1A62}, |
358 | {.Lower: 0x1A65, .Upper: 0x1A6C}, {.Lower: 0x1A73, .Upper: 0x1A7C}, {.Lower: 0x1A7F, .Upper: 0x1A7F}, |
359 | {.Lower: 0x1AB0, .Upper: 0x1ACE}, {.Lower: 0x1B00, .Upper: 0x1B03}, {.Lower: 0x1B34, .Upper: 0x1B34}, |
360 | {.Lower: 0x1B36, .Upper: 0x1B3A}, {.Lower: 0x1B3C, .Upper: 0x1B3C}, {.Lower: 0x1B42, .Upper: 0x1B42}, |
361 | {.Lower: 0x1B6B, .Upper: 0x1B73}, {.Lower: 0x1B80, .Upper: 0x1B81}, {.Lower: 0x1BA2, .Upper: 0x1BA5}, |
362 | {.Lower: 0x1BA8, .Upper: 0x1BA9}, {.Lower: 0x1BAB, .Upper: 0x1BAD}, {.Lower: 0x1BE6, .Upper: 0x1BE6}, |
363 | {.Lower: 0x1BE8, .Upper: 0x1BE9}, {.Lower: 0x1BED, .Upper: 0x1BED}, {.Lower: 0x1BEF, .Upper: 0x1BF1}, |
364 | {.Lower: 0x1C2C, .Upper: 0x1C33}, {.Lower: 0x1C36, .Upper: 0x1C37}, {.Lower: 0x1CD0, .Upper: 0x1CD2}, |
365 | {.Lower: 0x1CD4, .Upper: 0x1CE0}, {.Lower: 0x1CE2, .Upper: 0x1CE8}, {.Lower: 0x1CED, .Upper: 0x1CED}, |
366 | {.Lower: 0x1CF4, .Upper: 0x1CF4}, {.Lower: 0x1CF8, .Upper: 0x1CF9}, {.Lower: 0x1DC0, .Upper: 0x1DFF}, |
367 | {.Lower: 0x20D0, .Upper: 0x20F0}, {.Lower: 0x2CEF, .Upper: 0x2CF1}, {.Lower: 0x2D7F, .Upper: 0x2D7F}, |
368 | {.Lower: 0x2DE0, .Upper: 0x2DFF}, {.Lower: 0x302A, .Upper: 0x302D}, {.Lower: 0x3099, .Upper: 0x309A}, |
369 | {.Lower: 0xA66F, .Upper: 0xA672}, {.Lower: 0xA674, .Upper: 0xA67D}, {.Lower: 0xA69E, .Upper: 0xA69F}, |
370 | {.Lower: 0xA6F0, .Upper: 0xA6F1}, {.Lower: 0xA802, .Upper: 0xA802}, {.Lower: 0xA806, .Upper: 0xA806}, |
371 | {.Lower: 0xA80B, .Upper: 0xA80B}, {.Lower: 0xA825, .Upper: 0xA826}, {.Lower: 0xA82C, .Upper: 0xA82C}, |
372 | {.Lower: 0xA8C4, .Upper: 0xA8C5}, {.Lower: 0xA8E0, .Upper: 0xA8F1}, {.Lower: 0xA8FF, .Upper: 0xA8FF}, |
373 | {.Lower: 0xA926, .Upper: 0xA92D}, {.Lower: 0xA947, .Upper: 0xA951}, {.Lower: 0xA980, .Upper: 0xA982}, |
374 | {.Lower: 0xA9B3, .Upper: 0xA9B3}, {.Lower: 0xA9B6, .Upper: 0xA9B9}, {.Lower: 0xA9BC, .Upper: 0xA9BD}, |
375 | {.Lower: 0xA9E5, .Upper: 0xA9E5}, {.Lower: 0xAA29, .Upper: 0xAA2E}, {.Lower: 0xAA31, .Upper: 0xAA32}, |
376 | {.Lower: 0xAA35, .Upper: 0xAA36}, {.Lower: 0xAA43, .Upper: 0xAA43}, {.Lower: 0xAA4C, .Upper: 0xAA4C}, |
377 | {.Lower: 0xAA7C, .Upper: 0xAA7C}, {.Lower: 0xAAB0, .Upper: 0xAAB0}, {.Lower: 0xAAB2, .Upper: 0xAAB4}, |
378 | {.Lower: 0xAAB7, .Upper: 0xAAB8}, {.Lower: 0xAABE, .Upper: 0xAABF}, {.Lower: 0xAAC1, .Upper: 0xAAC1}, |
379 | {.Lower: 0xAAEC, .Upper: 0xAAED}, {.Lower: 0xAAF6, .Upper: 0xAAF6}, {.Lower: 0xABE5, .Upper: 0xABE5}, |
380 | {.Lower: 0xABE8, .Upper: 0xABE8}, {.Lower: 0xABED, .Upper: 0xABED}, {.Lower: 0xFB1E, .Upper: 0xFB1E}, |
381 | {.Lower: 0xFE00, .Upper: 0xFE0F}, {.Lower: 0xFE20, .Upper: 0xFE2F}, {.Lower: 0x101FD, .Upper: 0x101FD}, |
382 | {.Lower: 0x102E0, .Upper: 0x102E0}, {.Lower: 0x10376, .Upper: 0x1037A}, {.Lower: 0x10A01, .Upper: 0x10A03}, |
383 | {.Lower: 0x10A05, .Upper: 0x10A06}, {.Lower: 0x10A0C, .Upper: 0x10A0F}, {.Lower: 0x10A38, .Upper: 0x10A3A}, |
384 | {.Lower: 0x10A3F, .Upper: 0x10A3F}, {.Lower: 0x10AE5, .Upper: 0x10AE6}, {.Lower: 0x10D24, .Upper: 0x10D27}, |
385 | {.Lower: 0x10EAB, .Upper: 0x10EAC}, {.Lower: 0x10EFD, .Upper: 0x10EFF}, {.Lower: 0x10F46, .Upper: 0x10F50}, |
386 | {.Lower: 0x10F82, .Upper: 0x10F85}, {.Lower: 0x11001, .Upper: 0x11001}, {.Lower: 0x11038, .Upper: 0x11046}, |
387 | {.Lower: 0x11070, .Upper: 0x11070}, {.Lower: 0x11073, .Upper: 0x11074}, {.Lower: 0x1107F, .Upper: 0x11081}, |
388 | {.Lower: 0x110B3, .Upper: 0x110B6}, {.Lower: 0x110B9, .Upper: 0x110BA}, {.Lower: 0x110C2, .Upper: 0x110C2}, |
389 | {.Lower: 0x11100, .Upper: 0x11102}, {.Lower: 0x11127, .Upper: 0x1112B}, {.Lower: 0x1112D, .Upper: 0x11134}, |
390 | {.Lower: 0x11173, .Upper: 0x11173}, {.Lower: 0x11180, .Upper: 0x11181}, {.Lower: 0x111B6, .Upper: 0x111BE}, |
391 | {.Lower: 0x111C9, .Upper: 0x111CC}, {.Lower: 0x111CF, .Upper: 0x111CF}, {.Lower: 0x1122F, .Upper: 0x11231}, |
392 | {.Lower: 0x11234, .Upper: 0x11234}, {.Lower: 0x11236, .Upper: 0x11237}, {.Lower: 0x1123E, .Upper: 0x1123E}, |
393 | {.Lower: 0x11241, .Upper: 0x11241}, {.Lower: 0x112DF, .Upper: 0x112DF}, {.Lower: 0x112E3, .Upper: 0x112EA}, |
394 | {.Lower: 0x11300, .Upper: 0x11301}, {.Lower: 0x1133B, .Upper: 0x1133C}, {.Lower: 0x11340, .Upper: 0x11340}, |
395 | {.Lower: 0x11366, .Upper: 0x1136C}, {.Lower: 0x11370, .Upper: 0x11374}, {.Lower: 0x11438, .Upper: 0x1143F}, |
396 | {.Lower: 0x11442, .Upper: 0x11444}, {.Lower: 0x11446, .Upper: 0x11446}, {.Lower: 0x1145E, .Upper: 0x1145E}, |
397 | {.Lower: 0x114B3, .Upper: 0x114B8}, {.Lower: 0x114BA, .Upper: 0x114BA}, {.Lower: 0x114BF, .Upper: 0x114C0}, |
398 | {.Lower: 0x114C2, .Upper: 0x114C3}, {.Lower: 0x115B2, .Upper: 0x115B5}, {.Lower: 0x115BC, .Upper: 0x115BD}, |
399 | {.Lower: 0x115BF, .Upper: 0x115C0}, {.Lower: 0x115DC, .Upper: 0x115DD}, {.Lower: 0x11633, .Upper: 0x1163A}, |
400 | {.Lower: 0x1163D, .Upper: 0x1163D}, {.Lower: 0x1163F, .Upper: 0x11640}, {.Lower: 0x116AB, .Upper: 0x116AB}, |
401 | {.Lower: 0x116AD, .Upper: 0x116AD}, {.Lower: 0x116B0, .Upper: 0x116B5}, {.Lower: 0x116B7, .Upper: 0x116B7}, |
402 | {.Lower: 0x1171D, .Upper: 0x1171F}, {.Lower: 0x11722, .Upper: 0x11725}, {.Lower: 0x11727, .Upper: 0x1172B}, |
403 | {.Lower: 0x1182F, .Upper: 0x11837}, {.Lower: 0x11839, .Upper: 0x1183A}, {.Lower: 0x1193B, .Upper: 0x1193C}, |
404 | {.Lower: 0x1193E, .Upper: 0x1193E}, {.Lower: 0x11943, .Upper: 0x11943}, {.Lower: 0x119D4, .Upper: 0x119D7}, |
405 | {.Lower: 0x119DA, .Upper: 0x119DB}, {.Lower: 0x119E0, .Upper: 0x119E0}, {.Lower: 0x11A01, .Upper: 0x11A0A}, |
406 | {.Lower: 0x11A33, .Upper: 0x11A38}, {.Lower: 0x11A3B, .Upper: 0x11A3E}, {.Lower: 0x11A47, .Upper: 0x11A47}, |
407 | {.Lower: 0x11A51, .Upper: 0x11A56}, {.Lower: 0x11A59, .Upper: 0x11A5B}, {.Lower: 0x11A8A, .Upper: 0x11A96}, |
408 | {.Lower: 0x11A98, .Upper: 0x11A99}, {.Lower: 0x11C30, .Upper: 0x11C36}, {.Lower: 0x11C38, .Upper: 0x11C3D}, |
409 | {.Lower: 0x11C3F, .Upper: 0x11C3F}, {.Lower: 0x11C92, .Upper: 0x11CA7}, {.Lower: 0x11CAA, .Upper: 0x11CB0}, |
410 | {.Lower: 0x11CB2, .Upper: 0x11CB3}, {.Lower: 0x11CB5, .Upper: 0x11CB6}, {.Lower: 0x11D31, .Upper: 0x11D36}, |
411 | {.Lower: 0x11D3A, .Upper: 0x11D3A}, {.Lower: 0x11D3C, .Upper: 0x11D3D}, {.Lower: 0x11D3F, .Upper: 0x11D45}, |
412 | {.Lower: 0x11D47, .Upper: 0x11D47}, {.Lower: 0x11D90, .Upper: 0x11D91}, {.Lower: 0x11D95, .Upper: 0x11D95}, |
413 | {.Lower: 0x11D97, .Upper: 0x11D97}, {.Lower: 0x11EF3, .Upper: 0x11EF4}, {.Lower: 0x11F00, .Upper: 0x11F01}, |
414 | {.Lower: 0x11F36, .Upper: 0x11F3A}, {.Lower: 0x11F40, .Upper: 0x11F40}, {.Lower: 0x11F42, .Upper: 0x11F42}, |
415 | {.Lower: 0x13440, .Upper: 0x13440}, {.Lower: 0x13447, .Upper: 0x13455}, {.Lower: 0x16AF0, .Upper: 0x16AF4}, |
416 | {.Lower: 0x16B30, .Upper: 0x16B36}, {.Lower: 0x16F4F, .Upper: 0x16F4F}, {.Lower: 0x16F8F, .Upper: 0x16F92}, |
417 | {.Lower: 0x16FE4, .Upper: 0x16FE4}, {.Lower: 0x1BC9D, .Upper: 0x1BC9E}, {.Lower: 0x1CF00, .Upper: 0x1CF2D}, |
418 | {.Lower: 0x1CF30, .Upper: 0x1CF46}, {.Lower: 0x1D167, .Upper: 0x1D169}, {.Lower: 0x1D17B, .Upper: 0x1D182}, |
419 | {.Lower: 0x1D185, .Upper: 0x1D18B}, {.Lower: 0x1D1AA, .Upper: 0x1D1AD}, {.Lower: 0x1D242, .Upper: 0x1D244}, |
420 | {.Lower: 0x1DA00, .Upper: 0x1DA36}, {.Lower: 0x1DA3B, .Upper: 0x1DA6C}, {.Lower: 0x1DA75, .Upper: 0x1DA75}, |
421 | {.Lower: 0x1DA84, .Upper: 0x1DA84}, {.Lower: 0x1DA9B, .Upper: 0x1DA9F}, {.Lower: 0x1DAA1, .Upper: 0x1DAAF}, |
422 | {.Lower: 0x1E000, .Upper: 0x1E006}, {.Lower: 0x1E008, .Upper: 0x1E018}, {.Lower: 0x1E01B, .Upper: 0x1E021}, |
423 | {.Lower: 0x1E023, .Upper: 0x1E024}, {.Lower: 0x1E026, .Upper: 0x1E02A}, {.Lower: 0x1E08F, .Upper: 0x1E08F}, |
424 | {.Lower: 0x1E130, .Upper: 0x1E136}, {.Lower: 0x1E2AE, .Upper: 0x1E2AE}, {.Lower: 0x1E2EC, .Upper: 0x1E2EF}, |
425 | {.Lower: 0x1E4EC, .Upper: 0x1E4EF}, {.Lower: 0x1E8D0, .Upper: 0x1E8D6}, {.Lower: 0x1E944, .Upper: 0x1E94A}, |
426 | {.Lower: 0xE0100, .Upper: 0xE01EF}, |
427 | }; |
428 | static const UnicodeCharSet CombiningCharacters(CombiningCharacterRanges); |
429 | |
430 | if (CombiningCharacters.contains(C: UCS)) |
431 | return 0; |
432 | |
433 | // We consider double width codepoints any codepoint with |
434 | // the property East_Asian_Width=F|W |
435 | // + Misc Symbols and Pictographs (U+1F300...U+1F5FF) |
436 | // + Supplemental Symbols and Pictographs (U+1F900...U+1F9FF) |
437 | static const UnicodeCharRange DoubleWidthCharacterRanges[] = { |
438 | {.Lower: 0x1100, .Upper: 0x115F}, {.Lower: 0x231A, .Upper: 0x231B}, {.Lower: 0x2329, .Upper: 0x232A}, |
439 | {.Lower: 0x23E9, .Upper: 0x23EC}, {.Lower: 0x23F0, .Upper: 0x23F0}, {.Lower: 0x23F3, .Upper: 0x23F3}, |
440 | {.Lower: 0x25FD, .Upper: 0x25FE}, {.Lower: 0x2614, .Upper: 0x2615}, {.Lower: 0x2648, .Upper: 0x2653}, |
441 | {.Lower: 0x267F, .Upper: 0x267F}, {.Lower: 0x2693, .Upper: 0x2693}, {.Lower: 0x26A1, .Upper: 0x26A1}, |
442 | {.Lower: 0x26AA, .Upper: 0x26AB}, {.Lower: 0x26BD, .Upper: 0x26BE}, {.Lower: 0x26C4, .Upper: 0x26C5}, |
443 | {.Lower: 0x26CE, .Upper: 0x26CE}, {.Lower: 0x26D4, .Upper: 0x26D4}, {.Lower: 0x26EA, .Upper: 0x26EA}, |
444 | {.Lower: 0x26F2, .Upper: 0x26F3}, {.Lower: 0x26F5, .Upper: 0x26F5}, {.Lower: 0x26FA, .Upper: 0x26FA}, |
445 | {.Lower: 0x26FD, .Upper: 0x26FD}, {.Lower: 0x2705, .Upper: 0x2705}, {.Lower: 0x270A, .Upper: 0x270B}, |
446 | {.Lower: 0x2728, .Upper: 0x2728}, {.Lower: 0x274C, .Upper: 0x274C}, {.Lower: 0x274E, .Upper: 0x274E}, |
447 | {.Lower: 0x2753, .Upper: 0x2755}, {.Lower: 0x2757, .Upper: 0x2757}, {.Lower: 0x2795, .Upper: 0x2797}, |
448 | {.Lower: 0x27B0, .Upper: 0x27B0}, {.Lower: 0x27BF, .Upper: 0x27BF}, {.Lower: 0x2B1B, .Upper: 0x2B1C}, |
449 | {.Lower: 0x2B50, .Upper: 0x2B50}, {.Lower: 0x2B55, .Upper: 0x2B55}, {.Lower: 0x2E80, .Upper: 0x2E99}, |
450 | {.Lower: 0x2E9B, .Upper: 0x2EF3}, {.Lower: 0x2F00, .Upper: 0x2FD5}, {.Lower: 0x2FF0, .Upper: 0x303E}, |
451 | {.Lower: 0x3041, .Upper: 0x3096}, {.Lower: 0x3099, .Upper: 0x30FF}, {.Lower: 0x3105, .Upper: 0x312F}, |
452 | {.Lower: 0x3131, .Upper: 0x318E}, {.Lower: 0x3190, .Upper: 0x31E3}, {.Lower: 0x31EF, .Upper: 0x321E}, |
453 | {.Lower: 0x3220, .Upper: 0x3247}, {.Lower: 0x3250, .Upper: 0xA48C}, {.Lower: 0xA490, .Upper: 0xA4C6}, |
454 | {.Lower: 0xA960, .Upper: 0xA97C}, {.Lower: 0xAC00, .Upper: 0xD7A3}, {.Lower: 0xF900, .Upper: 0xFAFF}, |
455 | {.Lower: 0xFE10, .Upper: 0xFE19}, {.Lower: 0xFE30, .Upper: 0xFE52}, {.Lower: 0xFE54, .Upper: 0xFE66}, |
456 | {.Lower: 0xFE68, .Upper: 0xFE6B}, {.Lower: 0xFF01, .Upper: 0xFF60}, {.Lower: 0xFFE0, .Upper: 0xFFE6}, |
457 | {.Lower: 0x16FE0, .Upper: 0x16FE4}, {.Lower: 0x16FF0, .Upper: 0x16FF1}, {.Lower: 0x17000, .Upper: 0x187F7}, |
458 | {.Lower: 0x18800, .Upper: 0x18CD5}, {.Lower: 0x18D00, .Upper: 0x18D08}, {.Lower: 0x1AFF0, .Upper: 0x1AFF3}, |
459 | {.Lower: 0x1AFF5, .Upper: 0x1AFFB}, {.Lower: 0x1AFFD, .Upper: 0x1AFFE}, {.Lower: 0x1B000, .Upper: 0x1B122}, |
460 | {.Lower: 0x1B132, .Upper: 0x1B132}, {.Lower: 0x1B150, .Upper: 0x1B152}, {.Lower: 0x1B155, .Upper: 0x1B155}, |
461 | {.Lower: 0x1B164, .Upper: 0x1B167}, {.Lower: 0x1B170, .Upper: 0x1B2FB}, {.Lower: 0x1F004, .Upper: 0x1F004}, |
462 | {.Lower: 0x1F0CF, .Upper: 0x1F0CF}, {.Lower: 0x1F18E, .Upper: 0x1F18E}, {.Lower: 0x1F191, .Upper: 0x1F19A}, |
463 | {.Lower: 0x1F200, .Upper: 0x1F202}, {.Lower: 0x1F210, .Upper: 0x1F23B}, {.Lower: 0x1F240, .Upper: 0x1F248}, |
464 | {.Lower: 0x1F250, .Upper: 0x1F251}, {.Lower: 0x1F260, .Upper: 0x1F265}, {.Lower: 0x1F300, .Upper: 0x1F64F}, |
465 | {.Lower: 0x1F680, .Upper: 0x1F6C5}, {.Lower: 0x1F6CC, .Upper: 0x1F6CC}, {.Lower: 0x1F6D0, .Upper: 0x1F6D2}, |
466 | {.Lower: 0x1F6D5, .Upper: 0x1F6D7}, {.Lower: 0x1F6DC, .Upper: 0x1F6DF}, {.Lower: 0x1F6EB, .Upper: 0x1F6EC}, |
467 | {.Lower: 0x1F6F4, .Upper: 0x1F6FC}, {.Lower: 0x1F7E0, .Upper: 0x1F7EB}, {.Lower: 0x1F7F0, .Upper: 0x1F7F0}, |
468 | {.Lower: 0x1F900, .Upper: 0x1F9FF}, {.Lower: 0x1FA70, .Upper: 0x1FA7C}, {.Lower: 0x1FA80, .Upper: 0x1FA88}, |
469 | {.Lower: 0x1FA90, .Upper: 0x1FABD}, {.Lower: 0x1FABF, .Upper: 0x1FAC5}, {.Lower: 0x1FACE, .Upper: 0x1FADB}, |
470 | {.Lower: 0x1FAE0, .Upper: 0x1FAE8}, {.Lower: 0x1FAF0, .Upper: 0x1FAF8}, {.Lower: 0x20000, .Upper: 0x2FFFD}, |
471 | {.Lower: 0x30000, .Upper: 0x3FFFD}}; |
472 | static const UnicodeCharSet DoubleWidthCharacters(DoubleWidthCharacterRanges); |
473 | |
474 | if (DoubleWidthCharacters.contains(C: UCS)) |
475 | return 2; |
476 | return 1; |
477 | } |
478 | |
479 | static bool isprintableascii(char c) { return c > 31 && c < 127; } |
480 | |
481 | int columnWidthUTF8(StringRef Text) { |
482 | unsigned ColumnWidth = 0; |
483 | unsigned Length; |
484 | for (size_t i = 0, e = Text.size(); i < e; i += Length) { |
485 | Length = getNumBytesForUTF8(firstByte: Text[i]); |
486 | |
487 | // fast path for ASCII characters |
488 | if (Length == 1) { |
489 | if (!isprintableascii(c: Text[i])) |
490 | return ErrorNonPrintableCharacter; |
491 | ColumnWidth += 1; |
492 | continue; |
493 | } |
494 | |
495 | if (Length <= 0 || i + Length > Text.size()) |
496 | return ErrorInvalidUTF8; |
497 | UTF32 buf[1]; |
498 | const UTF8 *Start = reinterpret_cast<const UTF8 *>(Text.data() + i); |
499 | UTF32 *Target = &buf[0]; |
500 | if (conversionOK != ConvertUTF8toUTF32(sourceStart: &Start, sourceEnd: Start + Length, targetStart: &Target, |
501 | targetEnd: Target + 1, flags: strictConversion)) |
502 | return ErrorInvalidUTF8; |
503 | int Width = charWidth(UCS: buf[0]); |
504 | if (Width < 0) |
505 | return ErrorNonPrintableCharacter; |
506 | ColumnWidth += Width; |
507 | } |
508 | return ColumnWidth; |
509 | } |
510 | |
511 | } // namespace unicode |
512 | } // namespace sys |
513 | } // namespace llvm |
514 | |