@angadie/chittie-codepage 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Niels Leenheer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @angadie/chittie-codepage
2
+
3
+ Zero-dependency, Buffer-free code-page encoder — maps strings to printer byte values across 76 code pages (cp437, cp858, windows-1252, …). The low-level text-encoding layer under [`@angadie/chittie-core`](../chittie-core).
4
+
5
+ > **Vendored** from [`NielsLeenheer/CodepageEncoder`](https://github.com/NielsLeenheer/CodepageEncoder) @ `08e53e4` (MIT). Ships ESM source directly (no build step). See [`VENDOR.md`](../../VENDOR.md). You rarely use this directly — it's a building block.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @angadie/chittie-codepage
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import CodepageEncoder from '@angadie/chittie-codepage';
17
+
18
+ CodepageEncoder.encode('Hello', 'cp437'); // Uint8Array [48 65 6c 6c 6f]
19
+ CodepageEncoder.encode('é', 'cp858'); // Uint8Array [82]
20
+ CodepageEncoder.getEncodings(); // Codepage[] — all 76
21
+ CodepageEncoder.supports('cp858'); // boolean
22
+ ```
23
+
24
+ Characters absent from the target code page encode to `0x3f` (`?`). Sinhala, Tamil, and other complex scripts have **no** code page here — detect that with [`@angadie/chittie-text`](../chittie-text) and rasterize instead.
25
+
26
+ ## License
27
+
28
+ MIT — retains the upstream copyright (see `LICENSE`).
@@ -0,0 +1,15 @@
1
+ const aliases = {
2
+ 'cp2001': 'cp771',
3
+ 'cp1119': 'cp772',
4
+ 'cp1118': 'cp774',
5
+ 'cp1162': 'cp874',
6
+ 'iso88591': 'iso8859-1',
7
+ 'iso88592': 'iso8859-2',
8
+ 'iso88597': 'iso8859-7',
9
+ 'iso885915': 'iso8859-15',
10
+ 'shiftjis': 'epson/katakana',
11
+ 'katakana': 'epson/katakana',
12
+ 'cp928': 'star/cp928',
13
+ };
14
+
15
+ export default aliases;
@@ -0,0 +1,88 @@
1
+ export type Codepage =
2
+ | 'ascii'
3
+ | 'cp437'
4
+ | 'cp720'
5
+ | 'cp737'
6
+ | 'cp771'
7
+ | 'cp2001'
8
+ | 'cp772'
9
+ | 'cp1119'
10
+ | 'cp774'
11
+ | 'cp1118'
12
+ | 'cp775'
13
+ | 'cp850'
14
+ | 'cp851'
15
+ | 'cp852'
16
+ | 'cp853'
17
+ | 'cp855'
18
+ | 'cp857'
19
+ | 'cp858'
20
+ | 'cp860'
21
+ | 'cp861'
22
+ | 'cp862'
23
+ | 'cp863'
24
+ | 'cp864'
25
+ | 'cp865'
26
+ | 'cp866'
27
+ | 'cp869'
28
+ | 'cp874'
29
+ | 'cp1162'
30
+ | 'cp1001'
31
+ | 'cp1098'
32
+ | 'cp1125'
33
+ | 'cp3001'
34
+ | 'cp3002'
35
+ | 'cp3011'
36
+ | 'cp3012'
37
+ | 'cp3021'
38
+ | 'cp3041'
39
+ | 'cp3840'
40
+ | 'cp3841'
41
+ | 'cp3843'
42
+ | 'cp3844'
43
+ | 'cp3845'
44
+ | 'cp3846'
45
+ | 'cp3847'
46
+ | 'cp3848'
47
+ | 'iso8859-1'
48
+ | 'iso88591'
49
+ | 'iso8859-2'
50
+ | 'iso88592'
51
+ | 'iso8859-7'
52
+ | 'iso88597'
53
+ | 'iso8859-15'
54
+ | 'iso885915'
55
+ | 'windows1250'
56
+ | 'windows1251'
57
+ | 'windows1252'
58
+ | 'windows1253'
59
+ | 'windows1254'
60
+ | 'windows1255'
61
+ | 'windows1256'
62
+ | 'windows1257'
63
+ | 'windows1258'
64
+ | 'rk1048'
65
+ | 'thai11'
66
+ | 'thai13'
67
+ | 'thai14'
68
+ | 'thai16'
69
+ | 'thai18'
70
+ | 'thai42'
71
+ | 'tcvn3'
72
+ | 'tcvn3capitals'
73
+ | 'viscii'
74
+ | 'khmer'
75
+ | 'latvian'
76
+ | 'epson/katakana'
77
+ | 'shiftjis'
78
+ | 'katakana'
79
+ | 'epson/iso8859-2'
80
+ | 'star/standard'
81
+ | 'star/katakana'
82
+ | 'star/cp874'
83
+ | 'star/cp928'
84
+ | 'cp928'
85
+ | 'bixolon/cp866'
86
+ | 'bixolon/hebrew'
87
+ | 'xprinter/hebrew'
88
+ | 'pos8360/hebrew';
@@ -0,0 +1,542 @@
1
+ const definitions = {
2
+
3
+ 'ascii': {
4
+ name: 'ASCII',
5
+ languages: ['en'],
6
+ value: new Array(256).fill(1,0,128).map((v,i) => i),
7
+ },
8
+
9
+ 'cp437': {
10
+ name: 'USA, Standard Europe',
11
+ languages: ['en'],
12
+ extends: 'ascii',
13
+ value: [[,9786,9787,9829,9830,9827,9824,8226,9688,9675,9689,9794,9792,9834,9835,9788,],[9658,9668,8597,8252,182,167,9644,8616,8593,8595,8594,8592,8735,8596,9650,9660,],,,,,,[,,,,,,,,,,,,,,,8962,],[199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197,],[201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,402,],[225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187,],[9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488,],[9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575,],[9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600,],[945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745,],[8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160,],]
14
+ },
15
+
16
+ 'cp720': {
17
+ name: 'Arabic',
18
+ languages: ['ar'],
19
+ extends: 'cp437',
20
+ value: [,,,,,,,,[65533,65533,,,65533,,65533,,,,,,,65533,65533,65533,],[65533,1617,1618,,164,1600,,,1569,1570,1571,1572,,1573,1574,1575,],[1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,,,],,,,[1590,1591,1592,1593,1594,1601,,1602,1603,1604,1605,1606,1607,1608,1609,1610,],[,1611,1612,1613,1614,1615,1616,,,,,,,,,,],]
21
+ },
22
+
23
+ 'cp737': {
24
+ name: 'Greek',
25
+ languages: ['el'],
26
+ extends: 'cp437',
27
+ value: [,,,,,,,,[913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,],[929,931,932,933,934,935,936,937,945,946,947,948,949,950,951,952,],[953,954,955,956,957,958,959,960,961,963,962,964,965,966,967,968,],,,,[969,940,941,942,970,943,972,973,971,974,902,904,905,906,908,910,],[911,,,,938,939,,,,,,,,,,,],]
28
+ },
29
+
30
+ 'cp771': {
31
+ name: 'Lithuanian KBL',
32
+ languages: ['lt'],
33
+ extends: 'cp866',
34
+ value: [,,,,,,,,,,,,,[,,,,,,,,,,,,260,261,268,269,],,[280,281,278,279,302,303,352,353,370,371,362,363,381,382,,,],]
35
+ },
36
+
37
+ 'cp772': {
38
+ name: 'Lithuanian LST 1284',
39
+ languages: ['lt'],
40
+ extends: 'cp866',
41
+ value: [,,,,,,,,,,,[,,,,,260,268,280,278,,,,,302,352,,],[,,,,,,370,362,,,,,,,,381,],[261,269,281,279,303,353,371,363,382,,,,,,,,],,[,,8805,8804,8222,8220,247,8776,,,,,8319,178,,,],]
42
+ },
43
+
44
+ 'cp774': {
45
+ name: 'Lithuanian LST 1283',
46
+ languages: ['lt'],
47
+ extends: 'cp437',
48
+ value: [,,,,,,,,,,,[,,,,,260,268,280,278,,,,,302,352,,],[,,,,,,370,362,,,,,,,,381,],[261,269,281,279,303,353,371,363,382,,,,,,,,],[,946,,,,,,,,,,,,,,8898,],[,,,,8222,8220,,,,,729,,,,,,],]
49
+ },
50
+
51
+ 'cp775': {
52
+ name: 'Baltic Rim',
53
+ languages: ['et','lt'],
54
+ extends: 'cp437',
55
+ value: [,,,,,,,,[262,,,257,,291,,263,322,275,342,343,299,377,,,],[,,,333,,290,162,346,347,,,248,,216,215,164,],[256,298,,379,380,378,8221,166,169,174,,,,321,,,],[,,,,,260,268,280,278,,,,,302,352,,],[,,,,,,370,362,,,,,,,,381,],[261,269,281,279,303,353,371,363,382,,,,,,,,],[211,,332,323,245,213,,324,310,311,315,316,326,274,325,8217,],[173,,8220,190,182,167,,8222,,,,185,179,,,,],]
56
+ },
57
+
58
+ 'cp850': {
59
+ name: 'Multilingual',
60
+ languages: ['en'],
61
+ extends: 'cp437',
62
+ value: [,,,,,,,,,[,,,,,,,,,,,248,,216,215,,],[,,,,,,,,,174,,,,,,,],[,,,,,193,194,192,169,,,,,162,165,,],[,,,,,,227,195,,,,,,,,164,],[240,208,202,203,200,305,205,206,207,,,,,166,204,,],[211,,212,210,245,213,,254,222,218,219,217,253,221,175,180,],[173,,8215,190,182,167,,184,,168,,185,179,,,,],]
63
+ },
64
+
65
+ 'cp851': {
66
+ name: 'Greek',
67
+ languages: ['el'],
68
+ extends: 'cp437',
69
+ value: [,,,,,,,,[,,,,,,902,,,,,,,904,,905,],[906,65533,908,,,910,,,911,,,940,,941,942,943,],[970,912,972,973,913,914,915,916,917,918,919,,920,921,,,],[,,,,,922,923,924,925,,,,,926,927,,],[,,,,,,928,929,,,,,,,,931,],[932,933,934,935,936,937,945,946,947,,,,,948,949,,],[950,951,952,953,954,955,956,957,958,959,960,961,963,962,964,180,],[173,,965,966,967,167,968,184,,168,969,971,944,974,,,],]
70
+ },
71
+
72
+ 'cp852': {
73
+ name: 'Latin 2',
74
+ languages: ['hu','pl','cz'],
75
+ extends: 'cp850',
76
+ value: [,,,,,,,,[,,,,,367,263,,322,,336,337,,377,,262,],[,313,314,,,317,318,346,347,,,356,357,321,,269,],[,,,,260,261,381,382,280,281,,378,268,351,,,],[,,,,,,,282,350,,,,,379,380,,],[,,,,,,258,259,,,,,,,,,],[273,272,270,,271,327,,,283,,,,,354,366,,],[,,,323,324,328,352,353,340,,341,368,,,355,,],[,733,731,711,728,,,,,,729,369,344,345,,,],]
77
+ },
78
+
79
+ 'cp853': {
80
+ name: 'Turkish',
81
+ languages: ['tr'],
82
+ extends: 'cp437',
83
+ value: [,,,,,,,,[,,,,,,265,,,,,,,,,264,],[,267,266,,,,,,304,,,285,,284,215,309,],[,,,,,,286,287,292,293,65533,,308,351,,,],[,,,,,193,194,192,350,,,,,379,380,,],[,,,,,,348,349,,,,,,,,164,],[65533,65533,202,203,200,305,205,206,207,,,,,65533,204,,],[211,,212,210,288,289,,294,295,218,219,217,364,365,65533,180,],[173,65533,8467,329,728,167,,184,,168,729,65533,179,,,,],]
84
+ },
85
+
86
+ 'cp855': {
87
+ name: 'Cyrillic',
88
+ languages: ['bg'],
89
+ extends: 'cp437',
90
+ value: [,,,,,,,,[1106,1026,1107,1027,1105,1025,1108,1028,1109,1029,1110,1030,1111,1031,1112,1032,],[1113,1033,1114,1034,1115,1035,1116,1036,1118,1038,1119,1039,1102,1070,1098,1066,],[1072,1040,1073,1041,1094,1062,1076,1044,1077,1045,1092,1060,1075,1043,,,],[,,,,,1093,1061,1080,1048,,,,,1081,1049,,],[,,,,,,1082,1050,,,,,,,,164,],[1083,1051,1084,1052,1085,1053,1086,1054,1087,,,,,1055,1103,,],[1071,1088,1056,1089,1057,1090,1058,1091,1059,1078,1046,1074,1042,1100,1068,8470,],[173,1099,1067,1079,1047,1096,1064,1101,1069,1097,1065,1095,1063,167,,,],]
91
+ },
92
+
93
+ 'cp857': {
94
+ name: 'Turkish',
95
+ languages: ['tr'],
96
+ extends: 'cp437',
97
+ value: [,,,,,,,,[,,,,,,,,,,,,,305,,,],[,,,,,,,,304,,,248,,216,350,351,],[,,,,,,286,287,,174,,,,,,,],[,,,,,193,194,192,169,,,,,162,165,,],[,,,,,,227,195,,,,,,,,164,],[186,170,202,203,200,8364,205,206,207,,,,,166,204,,],[211,,212,210,245,213,,65533,215,218,219,217,236,255,175,180,],[173,,65533,190,182,167,,184,,168,,185,179,,,,],]
98
+ },
99
+
100
+ 'cp858': {
101
+ name: 'Euro',
102
+ languages: ['en'],
103
+ extends: 'cp850',
104
+ value: [,,,,,,,,,,,,,[,,,,,8364,,,,,,,,,,,],,,]
105
+ },
106
+
107
+ 'cp860': {
108
+ name: 'Portuguese',
109
+ languages: ['pt'],
110
+ extends: 'cp437',
111
+ value: [,,,,,,,,[,,,,227,,193,,,202,,205,212,,195,194,],[,192,200,,245,,218,,204,213,,,,217,,211,],[,,,,,,,,,210,,,,,,,],,,,,,]
112
+ },
113
+
114
+ 'cp861': {
115
+ name: 'Icelandic',
116
+ languages: ['is'],
117
+ extends: 'cp437',
118
+ value: [,,,,,,,,[,,,,,,,,,,,208,240,222,,,],[,,,,,254,,221,253,,,248,,216,,,],[,,,,193,205,211,218,,,,,,,,,],,,,,,]
119
+ },
120
+
121
+ 'cp862': {
122
+ name: 'Hebrew',
123
+ languages: ['he'],
124
+ extends: 'cp437',
125
+ value: [,,,,,,,,[1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,],[1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,,,,,,],,,,,,,]
126
+ },
127
+
128
+ 'cp863': {
129
+ name: 'Canadian French',
130
+ languages: ['fr'],
131
+ extends: 'cp437',
132
+ value: [,,,,,,,,[,,,,194,,182,,,,,,,8215,192,167,],[,200,202,,203,207,,,164,212,,,,217,219,,],[166,180,,,168,184,179,175,206,,,,,190,,,],,,,,,]
133
+ },
134
+
135
+ 'cp864': {
136
+ name: 'Arabic',
137
+ languages: ['ar'],
138
+ extends: 'cp437',
139
+ offset: 128,
140
+ value: [176,183,8729,8730,9618,9472,9474,9532,9508,9516,9500,9524,9488,9484,9492,9496,946,8734,966,177,189,188,8776,171,187,65271,65272,65533,65533,65275,65276,65533,160,173,65154,163,164,65156,65533,65533,65166,65167,65173,65177,1548,65181,65185,65189,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,65233,1563,65201,65205,65209,1567,162,65152,65153,65155,65157,65226,65163,65165,65169,65171,65175,65179,65183,65187,65191,65193,65195,65197,65199,65203,65207,65211,65215,65217,65221,65227,65231,166,172,247,215,65225,1600,65235,65239,65243,65247,65251,65255,65259,65261,65263,65267,65213,65228,65230,65229,65249,65149,1617,65253,65257,65260,65264,65266,65232,65237,65269,65270,65245,65241,65265,9632,65533]
141
+ },
142
+
143
+ 'cp865': {
144
+ name: 'Nordic',
145
+ languages: ['sv','dk'],
146
+ extends: 'cp437',
147
+ value: [,,,,,,,,,[,,,,,,,,,,,248,,216,,,],[,,,,,,,,,,,,,,,164,],,,,,,]
148
+ },
149
+
150
+ 'cp866': {
151
+ name: 'Cyrillic 2',
152
+ languages: ['ru'],
153
+ extends: 'cp437',
154
+ value: [,,,,,,,,[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,],[1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,],[1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,],,,,[1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,],[1025,1105,1028,1108,1031,1111,1038,1118,,,,,8470,164,,,],]
155
+ },
156
+
157
+ 'cp869': {
158
+ name: 'Greek',
159
+ languages: ['el'],
160
+ extends: 'cp437',
161
+ value: [,,,,,,,,[65533,65533,65533,65533,65533,65533,902,65533,183,172,166,8216,8217,904,8213,905,],[906,938,908,65533,65533,910,939,169,911,178,179,940,,941,942,943,],[970,912,972,973,913,914,915,916,917,918,919,,920,921,,,],[,,,,,922,923,924,925,,,,,926,927,,],[,,,,,,928,929,,,,,,,,931,],[932,933,934,935,936,937,945,946,947,,,,,948,949,,],[950,951,952,953,954,955,956,957,958,959,960,961,963,962,964,900,],[173,,965,966,967,167,968,901,,168,969,971,944,974,,,],]
162
+ },
163
+
164
+ 'cp874': {
165
+ name: 'Thai',
166
+ languages: ['th'],
167
+ extends: 'ascii',
168
+ offset: 128,
169
+ value: [8364,65533,65533,65533,65533,8230,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,8216,8217,8220,8221,8226,8211,8212,65533,65533,65533,65533,65533,65533,65533,65533,160,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,65533,65533,65533,65533,3647,3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,65533,65533,65533,65533]
170
+ },
171
+
172
+ 'cp1001': {
173
+ name: 'Arabic',
174
+ languages: ['ar'],
175
+ extends: 'cp437',
176
+ value: [,,,,,,,,[1569,1570,1571,1572,1573,65163,1575,1576,65169,1577,1578,65175,1579,65179,1583,1584,],[1585,1586,1587,65203,65204,1588,65207,65208,1589,65211,65212,1590,65215,65216,1591,1592,],[1593,65227,1594,65231,1601,65235,1602,65239,1603,1705,1604,65271,65273,65275,9496,1605,],[65251,1606,65255,1607,65259,1608,1609,1657,65267,9474,1548,1563,1567,65154,65156,65162,],[,1580,65183,1581,65187,1582,65191,65226,65228,65230,65231,65272,65274,65276,65259,65260,],[1632,65264,9472,65533,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,65533,65533,],[65533,65533,65275,65533,65533,65533,65533,9524,,,,,,,,,],,]
177
+ },
178
+
179
+ 'cp1098': {
180
+ name: 'Farsi',
181
+ languages: ['fa'],
182
+ extends: 'cp437',
183
+ value: [,,[,,,,,65533,,,,,65533,,,,,,],,,,,,[65533,65533,1548,1563,1567,1611,1570,65154,63738,1575,65166,63739,1569,1571,65156,63737,],[1572,65163,1576,65169,64342,64344,1578,65175,1579,65179,1580,65183,64378,64380,215,1581,],[65187,1582,65191,1583,1584,1585,1586,64394,1587,65203,1588,65207,1589,65211,,,],[,,,,,1590,65215,65217,65219,,,,,164,65221,,],[,,,,,,65223,1593,,,,,,,,65533,],[65226,65227,65228,1594,65230,65231,65232,1601,65235,,,,,1602,65239,,],[64398,65243,64402,64404,1604,65247,1605,65251,1606,65255,1608,1607,65259,65260,64420,64508,],[173,64509,64510,1600,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,,,],]
184
+ },
185
+
186
+ 'cp1125': {
187
+ name: 'Ukrainian',
188
+ languages: ['uk'],
189
+ extends: 'cp866',
190
+ value: [,,,,,,,,,,,,,,,[,,1168,1169,1028,1108,1030,1110,1031,1111,247,177,,,,,],]
191
+ },
192
+
193
+ 'cp3001': {
194
+ name: 'Estonian 1 or 1116',
195
+ languages: ['et'],
196
+ extends: 'cp850',
197
+ value: [,,,,,,,,,,,,,[353,352,,,,,,,,,,,,,,,],[,,,,,,,382,381,,,,,,,,],,]
198
+ },
199
+
200
+ 'cp3002': {
201
+ name: 'Estonian 2',
202
+ languages: ['et'],
203
+ extends: 'iso8859-1',
204
+ value: [,,,,,,,,[65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,],[65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,],[32,,,,,,,,,,,,,,,8254,],,,[352,,,,,,,,,,,,,,381,,],,[353,,,,,,,,,,,,,,382,,],]
205
+ },
206
+
207
+ 'cp3011': {
208
+ name: 'Latvian 1',
209
+ languages: ['lv'],
210
+ extends: 'cp437',
211
+ value: [,,,,,,,,,,,[,,,,,256,,326,,,,,,,,,],[,,,,,,257,,,,,,,,,,],[352,,269,268,,,291,298,299,,,,,363,362,,],,[274,275,290,311,310,316,315,382,381,,,,325,353,,,],]
212
+ },
213
+
214
+ 'cp3012': {
215
+ name: 'Latvian 2 (modified 866)',
216
+ languages: ['lv'],
217
+ extends: 'cp866',
218
+ value: [,,,,,,,,,,,[,,,,,256,,326,,,,,,332,,,],[,,,,,,257,,,,,,,,,,],[352,,269,268,,,291,298,299,,,,,363,362,,],,[274,275,290,311,310,316,315,382,381,333,,,325,353,,,],]
219
+ },
220
+
221
+ 'cp3021': {
222
+ name: 'Bulgarian (MIK)',
223
+ languages: ['bg'],
224
+ extends: 'cp866',
225
+ value: [,,,,,,,,,,,[1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,],[,,,,,,9571,9553,,,,,,,,9488,],[9617,9618,9619,9474,9508,8470,167,9559,9565,,,,,,,,],[945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745,],[8801,177,8805,8804,8992,8993,247,8776,,,,,8319,178,,,],]
226
+ },
227
+
228
+ 'cp3041': {
229
+ name: 'Maltese ISO 646',
230
+ languages: ['mt'],
231
+ extends: 'ascii',
232
+ value: [,,,,,[,,,,,,,,,,,289,380,295,,,],[267,,,,,,,,,,,,,,,,],[,,,,,,,,,,,288,379,294,266,,],,,,,,,,,]
233
+ },
234
+
235
+ 'cp3840': {
236
+ name: 'Russian (modified 866)',
237
+ languages: ['ru'],
238
+ extends: 'cp866',
239
+ value: [,,,,,,,,,,,,,,,[8801,177,8805,8804,8992,8993,247,8776,,,,,8319,178,,,],]
240
+ },
241
+
242
+ 'cp3841': {
243
+ name: 'Ghost',
244
+ languages: ['ru'],
245
+ extends: 'cp437',
246
+ offset: 128,
247
+ value: [1171,1241,1105,1110,1111,1112,1181,1257,1118,1199,1277,1224,1209,1207,1108,163,1170,1240,1025,1030,1031,1032,1180,1256,1038,1198,1276,1223,1208,1206,1028,1066,32,33,34,35,164,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,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,8709]
248
+ },
249
+
250
+ 'cp3843': {
251
+ name: 'Polish (Mazovia)',
252
+ languages: ['pl'],
253
+ extends: 'cp437',
254
+ value: [,,,,,,,,[,,,,,,261,,,,,,,263,,260,],[280,281,322,,,262,,,346,,,,321,,347,,],[377,379,,211,324,323,378,380,,,,,,,,,],,,,,,]
255
+ },
256
+
257
+ 'cp3844': {
258
+ name: 'Czech (Kamenický)',
259
+ languages: ['cz'],
260
+ extends: 'cp437',
261
+ value: [,,,,,,,,[268,,,271,,270,356,269,283,282,313,205,318,314,,193,],[,382,381,,,211,367,218,253,,,352,317,221,344,357,],[,,,,328,327,366,212,353,345,341,340,,167,,,],,,,,,]
262
+ },
263
+
264
+ 'cp3845': {
265
+ name: 'Hungarian (CWI-2)',
266
+ languages: ['hu'],
267
+ extends: 'cp437',
268
+ value: [,,,,,,,,[,,,,,,,,,,,,,205,,193,],[,,,337,,211,369,218,368,,,,,,,,],[,,,,,,,336,,,,,,,,,],,,,,,]
269
+ },
270
+
271
+ 'cp3846': {
272
+ name: 'Turkish',
273
+ languages: ['tr'],
274
+ extends: 'cp437',
275
+ value: [,,,,,,,,[,,,,,,,,,,,,,305,,,],[,,,,,,,,304,,,,,,350,351,],[,,,,,,286,287,,,,,,,,,],,,,,,]
276
+ },
277
+
278
+ 'cp3847': {
279
+ name: 'Brazil ABNT',
280
+ languages: ['pt'],
281
+ extends: 'iso8859-1',
282
+ value: [,,,,,,,,,,,,,[,,,,,,,65533,,,,,,,,,],,[,,,,,,,65533,,,,,,,,,],]
283
+ },
284
+
285
+ 'cp3848': {
286
+ name: 'Brazil ABICOMP',
287
+ languages: ['pt'],
288
+ extends: 'ascii',
289
+ value: [,,,,,,,,,,[160,192,193,194,195,196,199,200,201,202,203,204,205,206,205,209,],[210,211,212,213,214,198,217,218,219,220,376,168,163,166,167,176,],[161,224,225,226,227,228,231,232,233,234,235,236,237,238,239,241,],[242,243,244,245,246,230,249,250,251,252,255,223,170,186,191,177,],,,]
290
+ },
291
+
292
+ 'iso8859-1': {
293
+ name: 'Latin 1',
294
+ languages: ['en'],
295
+ extends: 'ascii',
296
+ offset: 128,
297
+ value: [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]
298
+ },
299
+
300
+ 'iso8859-2': {
301
+ name: 'Latin 2',
302
+ languages: ['hu','pl','cz'],
303
+ extends: 'iso8859-1',
304
+ value: [,,,,,,,,,,[,260,728,321,,317,346,,,352,350,356,377,,381,379,],[,261,731,322,,318,347,711,,353,351,357,378,733,382,380,],[340,,,258,,313,262,,268,,280,,282,,,270,],[272,323,327,,,336,,,344,366,,368,,,354,,],[341,,,259,,314,263,,269,,281,,283,,,271,],[273,324,328,,,337,,,345,367,,369,,,355,729,],]
305
+ },
306
+
307
+ 'iso8859-7': {
308
+ name: 'Greek',
309
+ languages: ['el'],
310
+ extends: 'iso8859-1',
311
+ value: [,,,,,,,,,,[,8216,8217,,8364,8367,,,,,890,,,,,8213,],[,,,,900,901,902,,904,905,906,,908,,910,911,],[912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,],[928,929,,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,,],]
312
+ },
313
+
314
+ 'iso8859-15': {
315
+ name: 'Latin 9',
316
+ languages: ['fr'],
317
+ extends: 'iso8859-1',
318
+ value: [,,,,,,,,,,[,,,,8364,,352,,353,,,,,,,,],[,,,,381,,,,382,,,,338,339,376,,],,,,,]
319
+ },
320
+
321
+ 'windows1250': {
322
+ name: 'Latin 2',
323
+ languages: ['hu','pl','cz'],
324
+ extends: 'windows1252',
325
+ value: [,,,,,,,,[,,,65533,,,,,65533,,,,346,356,,377,],[,,,,,,,,65533,,,,347,357,,378,],[,711,728,321,,260,,,,,350,,,,,379,],[,,731,322,,,,,,261,351,,317,733,318,380,],[340,,,258,,313,262,,268,,280,,282,,,270,],[272,323,327,,,336,,,344,366,,368,,,354,,],[341,,,259,,314,263,,269,,281,,283,,,271,],[273,324,328,,,337,,,345,367,,369,,,355,729,],]
326
+ },
327
+
328
+ 'windows1251': {
329
+ name: 'Cyrillic',
330
+ languages: ['ru'],
331
+ extends: 'windows1252',
332
+ value: [,,,,,,,,[1026,1027,,1107,,,,,8364,,1033,,1034,1036,1035,1039,],[1106,,,,,,,,65533,,1113,,1114,1116,1115,1119,],[,1038,1118,1032,,1168,,,1025,,1028,,,,,1031,],[,,1030,1110,1169,,,,1105,8470,1108,,1112,1029,1109,1111,],[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,],[1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,],[1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,],[1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,],]
333
+ },
334
+
335
+ 'windows1252': {
336
+ name: 'Latin',
337
+ languages: ['fr'],
338
+ extends: 'iso8859-1',
339
+ value: [,,,,,,,,[8364,65533,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,65533,381,65533,],[65533,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,65533,382,376,],,,,,,,]
340
+ },
341
+
342
+ 'windows1253': {
343
+ name: 'Greek',
344
+ languages: ['el'],
345
+ extends: 'windows1252',
346
+ value: [,,,,,,,,[,,,,,,,,65533,,65533,,65533,,65533,,],[,,,,,,,,65533,,65533,,65533,,65533,65533,],[,901,902,,,,,,,,65533,,,,,8213,],[,,,,900,,,,904,905,906,,908,,910,911,],[912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,],[928,929,65533,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,65533,],]
347
+ },
348
+
349
+ 'windows1254': {
350
+ name: 'Turkish',
351
+ languages: ['tr'],
352
+ extends: 'windows1252',
353
+ value: [,,,,,,,,[,,,,,,,,,,,,,,65533,,],[,,,,,,,,,,,,,,65533,,],,,,[286,,,,,,,,,,,,,304,350,,],,[287,,,,,,,,,,,,,305,351,,],]
354
+ },
355
+
356
+ 'windows1255': {
357
+ name: 'Hebrew',
358
+ languages: ['he'],
359
+ extends: 'windows1252',
360
+ value: [,,,,,,,,[,,,,,,,,,,65533,,65533,,65533,,],[,,,,,,,,,,65533,,65533,,65533,65533,],[,,,,8362,,,,,,215,,,,,,],[,,,,,,,,,,247,,,,,,],[1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,65533,1467,1468,1469,1470,1471,],[1472,1473,1474,1475,1520,1521,1522,1523,1524,65533,65533,65533,65533,65533,65533,65533,],[1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,],[1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,65533,65533,8206,8207,65533,],]
361
+ },
362
+
363
+ 'windows1256': {
364
+ name: 'Arabic',
365
+ languages: ['ar'],
366
+ extends: 'windows1252',
367
+ value: [,,,,,,,,[,1662,,,,,,,,,1657,,,1670,1688,1672,],[1711,,,,,,,,1705,,1681,,,8204,8205,1722,],[,1548,,,,,,,,,1726,,,,,,],[,,,,,,,,,,1563,,,,,1567,],[1729,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,],[1584,1585,1586,1587,1588,1589,1590,,1591,1592,1593,1594,1600,1601,1602,1603,],[,1604,,1605,1606,1607,1608,,,,,,1609,1610,,,],[1611,1612,1613,1614,,1615,1616,,1617,,1618,,,8206,8207,1746,],]
368
+ },
369
+
370
+ 'windows1257': {
371
+ name: 'Baltic Rim',
372
+ languages: ['et','lt'],
373
+ extends: 'windows1252',
374
+ value: [,,,,,,,,[,,,65533,,,,,65533,,65533,,65533,168,711,184,],[,,,,,,,,65533,,65533,,65533,175,731,65533,],[,65533,,,,65533,,,216,,342,,,,,198,],[,,,,,,,,248,,343,,,,,230,],[260,302,256,262,,,280,274,268,,377,278,290,310,298,315,],[352,323,325,,332,,,,370,321,346,362,,379,381,,],[261,303,257,263,,,281,275,269,,378,279,291,311,299,316,],[353,324,326,,333,,,,371,322,347,363,,380,382,729,],]
375
+ },
376
+
377
+ 'windows1258': {
378
+ name: 'Vietnamese',
379
+ languages: ['vi'],
380
+ extends: 'windows1252',
381
+ value: [,,,,,,,,[,,,,,,,,,,65533,,,,65533,,],[,,,,,,,,,,65533,,,,65533,,],,,[,,,258,,,,,,,,,768,,,,],[272,,777,,,416,,,,,,,,431,771,,],[,,,259,,,,,,,,,769,,,,],[273,,803,,,417,,,,,,,,432,8363,,],]
382
+ },
383
+
384
+ 'rk1048': {
385
+ name: 'Kazakh',
386
+ languages: ['kk'],
387
+ extends: 'windows1251',
388
+ value: [,,,,,,,,[,,,,,,,,,,,,,1178,1210,,],[,,,,,,,,,,,,,1179,1211,,],[,1200,1201,1240,,1256,,,,,1170,,,,,1198,],[,,,,1257,,,,,,1171,,1241,1186,1187,1199,],,,,,]
389
+ },
390
+
391
+ 'thai11': {
392
+ name: 'Thai (Charcter Code 11)',
393
+ languages: ['th'],
394
+ extends: 'thai13',
395
+ value: [,,,,,,,,,[,,,,,,,,,9484,9488,9492,9496,9474,9500,9508,],,,,[,,,,,,,,,,,9472,9524,9516,9532,,],,[,,,,,,,,,,,3658,3650,3651,3652,65533,],]
396
+ },
397
+
398
+ 'thai13': {
399
+ name: 'Thai (Charcter Code 13)',
400
+ languages: ['th'],
401
+ extends: 'cp874',
402
+ value: [,,,,,,,,[65533,,,,,65533,,,,,,,,,,,],[,65533,65533,65533,65533,65533,65533,65533,,,,,,,,,],,,,[,,,,,,,,,,,3619,,,3648,,],,[,,,,,,,,,,,,8592,8593,8594,8595,],]
403
+ },
404
+
405
+ 'thai14': {
406
+ name: 'Thai (Charcter Code 14)',
407
+ languages: ['th'],
408
+ extends: 'cp874',
409
+ value: [,,,,,,,,[9484,9488,9492,9496,9474,9472,9500,9508,9524,9516,9532,9608,,,,,],[3619,3634,65533,3632,65533,65533,65533,65533,,,,,,,,3648,],,,,,,[,,,,,,,,,,3675,65533,,,,3652,],]
410
+ },
411
+
412
+ 'thai16': {
413
+ name: 'Thai (Charcter Code 16)',
414
+ languages: ['th'],
415
+ extends: 'thai18',
416
+ value: [,,,,,,,,,[3650,3651,,,,,,,,,,,,,,,],,,,,,,]
417
+ },
418
+
419
+ 'thai18': {
420
+ name: 'Thai (Charcter Code 18)',
421
+ languages: ['th'],
422
+ extends: 'thai14',
423
+ value: [,,,,,,,,[,,,,,,,,,,,,8592,8593,8594,8595,],,,,,,[,,,,,,,,,,,,,,3652,,],[,,,,,,,,,,,,,,,65533,],]
424
+ },
425
+
426
+ 'thai42': {
427
+ name: 'Thai (Charcter Code 42)',
428
+ languages: ['th'],
429
+ extends: 'thai18',
430
+ value: [,,,,,,,,,[3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3587,3589,3619,3634,3652,,],[,,,3588,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,],[3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,],[3618,3619,3620,3621,3623,3624,3625,3626,3627,3628,3629,3630,3632,3622,3634,3635,],[3648,3649,3650,3651,3652,3654,3631,3640,3641,3636,3637,3638,3639,3658,3661,3655,],[3656,3657,3658,3659,3660,65533,65533,65533,65533,65533,65533,3632,65533,65533,65533,65533,],[65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,65533,,,,,160,],]
431
+ },
432
+
433
+ 'tcvn3': {
434
+ name: 'Vietnamese (VSCII3 / TCVN3)',
435
+ languages: ['vi'],
436
+ extends: 'ascii',
437
+ value: [,,,,,,,,,,[,,,,,,,,259,226,234,244,417,432,273,,],[,,,,,224,7843,227,225,7841,,7857,7859,7861,7855,,],[,,,,,,7863,7847,7849,7851,7845,7853,232,,7867,7869,],[233,7865,7873,7875,7877,7871,7879,236,7881,,,,297,237,7883,242,],[,7887,245,243,7885,7891,7893,7895,7889,7897,7901,7903,7905,7899,7907,249,],[,7911,361,250,7909,7915,7917,7919,7913,7921,7923,7927,7929,253,7925,,],]
438
+ },
439
+
440
+ 'tcvn3capitals': {
441
+ name: 'Vietnamese (VSCII3 / TCVN3 Capitals)',
442
+ languages: ['vi'],
443
+ extends: 'ascii',
444
+ value: [,,,,,,,,,,[,258,194,,,,,208,,,202,212,416,431,,,],[,,,,,192,7842,195,193,7840,,7856,7858,7860,7854,,],[,,,,,,7862,7846,7848,7850,7844,7852,200,,7866,7868,],[201,7864,7872,7874,7876,7870,7878,204,7880,,,,296,205,7882,210,],[,7886,213,211,7884,7890,7892,7894,7888,7896,7900,7902,7904,7898,7906,217,],[,7910,360,218,7908,7914,7916,7918,7912,7920,7922,7926,7928,221,7924,,],]
445
+ },
446
+
447
+ 'viscii': {
448
+ name: 'Vietnamese (VISCII)',
449
+ languages: ['vi'],
450
+ extends: 'ascii',
451
+ value: [[,,7858,,,7860,7850,,,,,,,,,,],[,,,,7926,,,,,7928,,,,,7924,,],,,,,,,[7840,7854,7856,7862,7844,7846,7848,7852,7868,7864,7870,7872,7874,7876,7878,7888,],[7890,7892,7894,7896,7906,7898,7900,7902,7882,7886,7884,7880,7910,360,7908,7922,],[213,7855,7857,7863,7845,7847,7849,7853,7869,7865,7871,7873,7875,7877,7879,7889,],[7891,7893,7895,7904,416,7897,7901,7903,7883,7920,7912,7914,7916,417,7899,431,],[192,193,194,195,7842,258,7859,7861,200,201,202,7866,204,205,296,7923,],[272,7913,210,211,212,7841,7927,7915,7917,217,218,7929,7925,221,7905,432,],[224,225,226,227,7843,259,7919,7851,232,233,234,7867,236,237,297,7881,],[273,7921,242,243,244,245,7887,7885,7909,249,250,361,7911,253,7907,7918,],]
452
+ },
453
+
454
+ 'khmer': {
455
+ name: 'Khmer',
456
+ languages: ['km'],
457
+ extends: 'ascii',
458
+ value: [,,,,,,,,[6016,6017,6016,6019,6020,6021,6022,6023,6024,6025,6026,6027,6028,6029,6030,6031,],[6032,6033,6032,6035,6036,6037,6038,6039,6040,6041,6042,6043,6044,6045,6046,6047,],[6048,6049,6048,6051,6052,6053,6054,6055,6056,6057,6058,6059,6060,6061,6062,6063,],[6064,6065,6064,6067,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,],[6080,6081,6080,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,],[6096,6097,6096,6099,6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,,,],[6112,6113,6112,6115,6116,6117,6118,6119,6120,6121,,,,,,,],[6128,6129,6128,6131,6132,6133,6134,,,,,,,,,,],]
459
+ },
460
+
461
+ 'latvian': {
462
+ name: 'Latvian (based on cp3012)',
463
+ languages: ['lv'],
464
+ extends: 'cp3012',
465
+ value: [,,,,,,,,,,,,,[,,,,298,299,,,,,,,,,,,],,,]
466
+ },
467
+
468
+ 'epson/katakana': {
469
+ name: 'Katakana',
470
+ languages: ['ja'],
471
+ extends: 'cp437',
472
+ offset: 128,
473
+ value: [9601,9602,9603,9604,9605,9606,9607,9608,9615,9614,9613,9612,9611,9610,9609,9532,9524,9516,9508,9500,9620,9472,9474,9621,9484,9488,9492,9496,9581,9582,9584,9583,32,65377,65378,65379,65380,65381,65382,65383,65384,65385,65386,65387,65388,65389,65390,65391,65392,65393,65394,65395,65396,65397,65398,65399,65400,65401,65402,65403,65404,65405,65406,65407,65408,65409,65410,65411,65412,65413,65414,65415,65416,65417,65418,65419,65420,65421,65422,65423,65424,65425,65426,65427,65428,65429,65430,65431,65432,65433,65434,65435,65436,65437,65438,65439,9552,9566,9578,9569,9698,9699,9701,9700,9824,9829,9830,9827,9679,9675,9585,9586,9587,20870,24180,26376,26085,26178,20998,31186,12306,24066,21306,30010,26449,20154,9618,160]
474
+ },
475
+
476
+ 'epson/iso8859-2': {
477
+ name: 'Latin 2 modified with box drawing characters',
478
+ languages: ['hu','pl','cz'],
479
+ extends: 'iso8859-2',
480
+ value: [,,,,,,,,[9617,9618,9619,9474,9508,9496,9484,9608,169,9571,9553,9559,9565,162,165,9488,],[9492,9524,9516,9500,9472,9532,9604,9600,9562,9556,9577,9574,9568,9552,9580,174,],,,,,,,]
481
+ },
482
+
483
+ 'star/standard': {
484
+ name: 'Standard',
485
+ languages: ['en'],
486
+ extends: 'cp437',
487
+ offset: 128,
488
+ value: [160,129904,129910,129905,129911,129906,129912,129907,129913,129908,129914,129909,9500,129915,129916,129918,129919,129917,9624,9623,9622,9629,9585,9586,9701,9700,9484,9524,9516,9508,9830,9587,196,214,220,223,167,170,186,65533,162,189,65533,65533,165,188,256,235,233,232,275,234,239,237,236,299,238,246,243,242,333,244,252,250,249,363,251,231,191,65533,65533,274,8580,161,197,248,216,228,225,224,257,226,176,8451,8457,937,181,931,963,65533,65533,967,8734,177,247,960,9612,9604,9600,9616,9532,9496,9492,9488,9608,9618,9162,8592,8593,8594,8595,9581,9161,129923,65533,9601,9613,65533,129928,9626,9630,9698,9699,129840,9208,9584,9583,9582]
489
+ },
490
+
491
+ 'star/katakana': {
492
+ name: 'Katakana',
493
+ languages: ['ja'],
494
+ extends: 'star/standard',
495
+ value: [,,,,,,,,,,[32,65377,65378,65379,65380,65381,65382,65383,65384,65385,65386,65387,65388,65389,65390,65391,],[65392,65393,65394,65395,65396,65397,65398,65399,65400,65401,65402,65403,65404,65405,65406,65407,],[65408,65409,65410,65411,65412,65413,65414,65415,65416,65417,65418,65419,65420,65421,65422,65423,],[65424,65425,65426,65427,65428,65429,65430,65431,65432,65433,65434,65435,65436,65437,65438,65439,],,,]
496
+ },
497
+
498
+ 'star/cp874': {
499
+ name: 'Thai',
500
+ languages: ['th'],
501
+ extends: 'cp874',
502
+ value: [,,,,,,,,,[,,,,,9474,9472,9532,9484,9488,9492,9496,9500,9516,9508,9524,],,,,[,,,,,,,,,,,3657,3658,3659,3660,,],,[,,,,,,,,,,,,162,172,166,,],]
503
+ },
504
+
505
+ 'star/cp928': {
506
+ name: 'Greek',
507
+ languages: ['el'],
508
+ extends: 'cp437',
509
+ value: [,,,,,,,,,,[160,8216,8217,163,65533,65533,166,167,168,169,65533,171,172,173,65533,8213,],[176,177,178,179,900,901,902,183,904,905,906,187,908,189,910,911,],[912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,],[928,929,65533,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,65533,],]
510
+ },
511
+
512
+ 'bixolon/cp866': {
513
+ name: 'Cyrillic 2 (modified with euro sign)',
514
+ languages: ['ru'],
515
+ extends: 'cp866',
516
+ value: [,,,,,,,,,,,,,,,[,,,,9093,1055,8801,9824,8364,,,,,,,,],]
517
+ },
518
+
519
+ 'bixolon/hebrew': {
520
+ name: 'Hebrew',
521
+ languages: ['he'],
522
+ extends: 'cp437',
523
+ value: [,,,,,,,,,,[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,],[1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,],[1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,123,124,125,126,,],]
524
+ },
525
+
526
+ 'xprinter/hebrew': {
527
+ name: 'Hebrew (based on CP862 minus CP437)',
528
+ languages: ['he'],
529
+ extends: 'ascii',
530
+ value: [,,,,,,,,[1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,],[1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,,,,,,],,,,,,,]
531
+ },
532
+
533
+ 'pos8360/hebrew': {
534
+ name: 'Hebrew (based on cp862 with repeated characters)',
535
+ languages: ['he'],
536
+ extends: 'cp862',
537
+ value: [,,,,,,,,,,,,,,[1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,],[1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,,,,,,],]
538
+ },
539
+
540
+ };
541
+
542
+ export default definitions;
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@angadie/chittie-codepage",
3
+ "version": "0.1.0",
4
+ "description": "Zero-dependency code-page encoder for thermal printers (vendored from @point-of-sale/codepage-encoder, MIT).",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "types": "./types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./types/index.d.ts",
11
+ "import": "./src/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "src",
16
+ "generated",
17
+ "types",
18
+ "LICENSE"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "scripts": {
24
+ "build": "echo 'chittie-codepage ships ESM source (no build step)'",
25
+ "typecheck": "echo 'no typecheck (vendored JS + shipped .d.ts)'",
26
+ "test": "node spikes/encode.spike.mjs"
27
+ }
28
+ }
@@ -0,0 +1,258 @@
1
+ import definitions from '../generated/definitions.js';
2
+ import aliases from '../generated/aliases.js';
3
+ import strings from './strings.js';
4
+
5
+ /** @import { Codepage } from '../generated/codepage.js' */
6
+
7
+ /**
8
+ * @typedef {Object} CodepageEncoding
9
+ * @property {string} name
10
+ * @property {string[]} [languages]
11
+ * @property {string} [extends]
12
+ * @property {number} [offset]
13
+ * @property {number[]} codepoints
14
+ */
15
+
16
+ /**
17
+ * @typedef {Object} TestString
18
+ * @property {string} language
19
+ * @property {string} string
20
+ */
21
+
22
+ /**
23
+ * @typedef {Object} AutoEncodeFragment
24
+ * @property {Codepage} codepage
25
+ * @property {Uint8Array} bytes
26
+ */
27
+
28
+ /**
29
+ * A library for converting Unicode to obscure single byte codepage for use with thermal printers
30
+ */
31
+ class CodepageEncoder {
32
+ /**
33
+ * Get list of supported codepages
34
+ *
35
+ * @return {Codepage[]} Return an array with the supported codepages
36
+ *
37
+ */
38
+ static getEncodings() {
39
+ return Object.keys(definitions);
40
+ }
41
+
42
+ /**
43
+ * Get codepage definition
44
+ *
45
+ * @param {Codepage} codepage The codepage, defaults to ascii when it cannot find the codepage
46
+ * @return {CodepageEncoding} Return an object with the codepage definition
47
+ *
48
+ */
49
+ static getEncoding(codepage) {
50
+ if (typeof aliases[codepage] !== 'undefined') {
51
+ codepage = aliases[codepage];
52
+ }
53
+
54
+ if (typeof definitions[codepage] === 'undefined') {
55
+ codepage = 'ascii';
56
+ }
57
+
58
+ /* Create codepoints array if it doesn't exist */
59
+
60
+ if (typeof definitions[codepage].codepoints === 'undefined') {
61
+ definitions[codepage].codepoints = this.getCodepoints(codepage, true);
62
+ }
63
+
64
+ /* Return codepage definition */
65
+
66
+ return structuredClone(definitions[codepage]);
67
+ }
68
+
69
+
70
+ /**
71
+ * Get test strings for the specified codepage
72
+ *
73
+ * @param {Codepage} codepage The codepage
74
+ * @return {TestString[]} Return an array with one or more objects
75
+ * containing a property for the language of
76
+ * the string and a property for the string itself
77
+ *
78
+ */
79
+ static getTestStrings(codepage) {
80
+ if (typeof aliases[codepage] !== 'undefined') {
81
+ codepage = aliases[codepage];
82
+ }
83
+
84
+ if (typeof definitions[codepage] !== 'undefined' &&
85
+ typeof definitions[codepage].languages !== 'undefined') {
86
+ return definitions[codepage].languages.map((i) => ({language: i, string: strings[i]}));
87
+ }
88
+
89
+ return [];
90
+ }
91
+
92
+ /**
93
+ * Determine if the specified codepage is supported
94
+ *
95
+ * @param {string} codepage The codepage
96
+ * @return {boolean} Return a boolean, true if the encoding is supported,
97
+ * otherwise false
98
+ *
99
+ */
100
+ static supports(codepage) {
101
+ if (typeof aliases[codepage] !== 'undefined') {
102
+ codepage = aliases[codepage];
103
+ }
104
+
105
+ if (typeof definitions[codepage] === 'undefined') {
106
+ return false;
107
+ }
108
+
109
+ return true;
110
+ }
111
+
112
+ /**
113
+ * Encode a string in the specified codepage
114
+ *
115
+ * @param {string} input Text that needs encoded to the specified codepage
116
+ * @param {Codepage} codepage The codepage
117
+ * @return {Uint8Array} Return an array of bytes with the encoded string
118
+ *
119
+ */
120
+ static encode(input, codepage) {
121
+ const output = new Uint8Array(input.length);
122
+ const definition = this.getEncoding(codepage);
123
+
124
+ for (let c = 0; c < input.length; c++) {
125
+ const codepoint = input.codePointAt(c);
126
+ const position = definition.codepoints.findIndex((i) => i === codepoint);
127
+
128
+ if (position !== -1) {
129
+ output[c] = position;
130
+ } else {
131
+ output[c] = 0x3f;
132
+ }
133
+ }
134
+
135
+ return output;
136
+ }
137
+
138
+ /**
139
+ * Encode a string in the most optimal set of codepages.
140
+ *
141
+ * @param {string} input Text that needs encoded
142
+ * @param {Codepage[]} candidates An array of candidate codepages that are allowed to be used, ranked by importance
143
+ * @return {AutoEncodeFragment[]} Return an array of fragments with the encoded string
144
+ *
145
+ */
146
+ static autoEncode(input, candidates) {
147
+ const fragments = [];
148
+ let fragment = -1;
149
+ let current;
150
+
151
+ for (let c = 0; c < input.length; c++) {
152
+ const codepoint = input.codePointAt(c);
153
+
154
+ let available;
155
+ let char = 0;
156
+
157
+ if (!available && current) {
158
+ const definition = this.getEncoding(current);
159
+ const position = definition.codepoints.findIndex((i) => i === codepoint);
160
+
161
+ if (position !== -1) {
162
+ available = current;
163
+ char = position;
164
+ }
165
+ }
166
+
167
+ if (!available) {
168
+ for (let i = 0; i < candidates.length; i++) {
169
+ const definition = this.getEncoding(candidates[i]);
170
+ const position = definition.codepoints.findIndex((i) => i === codepoint);
171
+
172
+ if (position !== -1) {
173
+ available = candidates[i];
174
+ char = position;
175
+ break;
176
+ }
177
+ }
178
+ }
179
+
180
+ if (!available) {
181
+ available = current || candidates[0];
182
+ char = 0x3f;
183
+ }
184
+
185
+ if (current != available) {
186
+ if (current) {
187
+ fragments[fragment].bytes = new Uint8Array(fragments[fragment].bytes);
188
+ }
189
+
190
+ fragment++;
191
+ fragments[fragment] = {
192
+ codepage: available,
193
+ bytes: [],
194
+ };
195
+
196
+ current = available;
197
+ }
198
+
199
+ fragments[fragment].bytes.push(char);
200
+ }
201
+
202
+ if (current) {
203
+ fragments[fragment].bytes = new Uint8Array(fragments[fragment].bytes);
204
+ }
205
+
206
+ return fragments;
207
+ }
208
+
209
+ /**
210
+ * Get codepoints
211
+ *
212
+ * @param {Codepage} codepage The codepage
213
+ * @param {boolean} evaluateExtends Evaluate the extends property
214
+ * @return {number[]} Return an array with 256 codepoints for the specified codepage
215
+ *
216
+ */
217
+ static getCodepoints(codepage, evaluateExtends) {
218
+ let codepoints = new Array(256);
219
+
220
+ if (evaluateExtends) {
221
+ if (typeof definitions[codepage].extends === 'undefined') {
222
+ codepoints = codepoints.fill(0xfffd);
223
+ } else {
224
+ codepoints = this.getEncoding(definitions[codepage].extends).codepoints;
225
+ }
226
+ }
227
+
228
+ if (definitions[codepage].value.length === 16) {
229
+ for (let i = 0; i < 16; i++) {
230
+ if (typeof definitions[codepage].value[i] !== 'object') {
231
+ continue;
232
+ }
233
+
234
+ for (let j = 0; j < 16; j++) {
235
+ if (typeof definitions[codepage].value[i][j] !== 'number') {
236
+ continue;
237
+ }
238
+
239
+ codepoints[i * 16 + j] = definitions[codepage].value[i][j];
240
+ }
241
+ }
242
+ } else {
243
+ const offset = definitions[codepage].offset || 0;
244
+
245
+ for (let i = 0; i < definitions[codepage].value.length; i++) {
246
+ if (typeof definitions[codepage].value[i] !== 'number') {
247
+ continue;
248
+ }
249
+
250
+ codepoints[offset + i] = definitions[codepage].value[i];
251
+ }
252
+ }
253
+
254
+ return codepoints;
255
+ }
256
+ }
257
+
258
+ export default CodepageEncoder;
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './codepage-encoder.js';
2
+ export { default as CodepageEncoder } from './codepage-encoder.js';
package/src/strings.js ADDED
@@ -0,0 +1,30 @@
1
+
2
+ const strings = {
3
+ en: 'The quick brown fox jumps over the lazy dog.',
4
+ jp: 'イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム',
5
+ pt: 'O próximo vôo à noite sobre o Atlântico, põe freqüentemente o único médico.',
6
+ fr: 'Les naïfs ægithales hâtifs pondant à Noël où il gèle sont sûrs d\'être déçus en voyant leurs drôles d\'œufs abîmés.',
7
+ sv: 'Flygande bäckasiner söka strax hwila på mjuka tuvor.',
8
+ dk: 'Quizdeltagerne spiste jordbær med fløde',
9
+ el: 'ξεσκεπάζω την ψυχοφθόρα βδελυγμία',
10
+ tr: 'Pijamalı hasta, yağız şoföre çabucak güvendi.',
11
+ ru: 'Съешь же ещё этих мягких французских булок да выпей чаю',
12
+ hu: 'Árvíztűrő tükörfúrógép',
13
+ pl: 'Pchnąć w tę łódź jeża lub ośm skrzyń fig',
14
+ cz: 'Mohu jíst sklo, neublíží mi.',
15
+ ar: 'أنا قادر على أكل الزجاج و هذا لا يؤلمني.',
16
+ et: 'Ma võin klaasi süüa, see ei tee mulle midagi.',
17
+ lt: 'Aš galiu valgyti stiklą ir jis manęs nežeidžia.',
18
+ bg: 'Мога да ям стъкло, то не ми вреди.',
19
+ is: 'Ég get etið gler án þess að meiða mig.',
20
+ he: 'אני יכול לאכול זכוכית וזה לא מזיק לי.',
21
+ fa: '.من می توانم بدونِ احساس درد شيشه بخورم',
22
+ uk: 'Я можу їсти скло, і воно мені не зашкодить.',
23
+ vi: 'Tôi có thể ăn thủy tinh mà không hại gì.',
24
+ kk: 'қазақша',
25
+ lv: 'Es varu ēst stiklu, tas man nekaitē.',
26
+ mt: 'Nista\' niekol il-ħġieġ u ma jagħmilli xejn.',
27
+ th: 'ฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บ',
28
+ };
29
+
30
+ export default strings;
@@ -0,0 +1,29 @@
1
+ type Codepage = 'ascii' | 'cp437' | 'cp720' | 'cp737' | 'cp771' | 'cp2001' | 'cp772' | 'cp1119' | 'cp774' | 'cp1118' | 'cp775' | 'cp850' | 'cp851' | 'cp852' | 'cp853' | 'cp855' | 'cp857' | 'cp858' | 'cp860' | 'cp861' | 'cp862' | 'cp863' | 'cp864' | 'cp865' | 'cp866' | 'cp869' | 'cp874' | 'cp1162' | 'cp1001' | 'cp1098' | 'cp1125' | 'cp3001' | 'cp3002' | 'cp3011' | 'cp3012' | 'cp3021' | 'cp3041' | 'cp3840' | 'cp3841' | 'cp3843' | 'cp3844' | 'cp3845' | 'cp3846' | 'cp3847' | 'cp3848' | 'iso8859-1' | 'iso88591' | 'iso8859-2' | 'iso88592' | 'iso8859-7' | 'iso88597' | 'iso8859-15' | 'iso885915' | 'windows1250' | 'windows1251' | 'windows1252' | 'windows1253' | 'windows1254' | 'windows1255' | 'windows1256' | 'windows1257' | 'windows1258' | 'rk1048' | 'thai11' | 'thai13' | 'thai14' | 'thai16' | 'thai18' | 'thai42' | 'tcvn3' | 'tcvn3capitals' | 'viscii' | 'khmer' | 'latvian' | 'epson/katakana' | 'shiftjis' | 'katakana' | 'epson/iso8859-2' | 'star/standard' | 'star/katakana' | 'star/cp874' | 'star/cp928' | 'cp928' | 'bixolon/cp866' | 'bixolon/hebrew' | 'xprinter/hebrew' | 'pos8360/hebrew';
2
+
3
+ type CodepageEncoding = {
4
+ name: string;
5
+ languages?: string[];
6
+ extends?: string;
7
+ offset?: number;
8
+ codepoints: number[];
9
+ };
10
+ type TestString = {
11
+ language: string;
12
+ string: string;
13
+ };
14
+ type AutoEncodeFragment = {
15
+ codepage: Codepage;
16
+ bytes: Uint8Array;
17
+ };
18
+ declare class CodepageEncoder {
19
+ static getEncodings(): Codepage[];
20
+ static getEncoding(codepage: Codepage): CodepageEncoding;
21
+ static getTestStrings(codepage: Codepage): TestString[];
22
+ static supports(codepage: string): boolean;
23
+ static encode(input: string, codepage: Codepage): Uint8Array;
24
+ static autoEncode(input: string, candidates: Codepage[]): AutoEncodeFragment[];
25
+ static getCodepoints(codepage: Codepage, evaluateExtends: boolean): number[];
26
+ }
27
+
28
+ export { CodepageEncoder as default };
29
+ export type { AutoEncodeFragment, Codepage, CodepageEncoding, TestString };