tibetan-ansi-to-unicode 1.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/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # tibetan-unicode-converter
2
+
3
+ A library for converting ANSI Tibetan from TibetanChogyal to Unicode and back.
4
+
5
+ Almost all Tibetan characters should be properly transcoded but only a few
6
+ Sanskrit characters are currently handled.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install tibetan-unicode-converter
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ### ANSI to Unicode
17
+
18
+ ```js
19
+ import TibetanUnicodeConverter from "tibetan-unicode-converter";
20
+
21
+ const converter = new TibetanUnicodeConverter(
22
+ "oe×ñÎ >ë-{,-8ß:-bÜ-¹¥/-e$-020<Î"
23
+ );
24
+ converter.convert();
25
+ // => 'ཧཱུྃ༔ ཨོ་རྒྱན་ཡུལ་གྱི་ནུབ་བྱང་མཚམས༔'
26
+ ```
27
+
28
+ ### Unicode to ANSI
29
+
30
+ ```js
31
+ import TibetanUnicodeConverter from "tibetan-unicode-converter";
32
+
33
+ const converter = new TibetanUnicodeConverter("ཧཱུྃ༔");
34
+ converter.convertToAnsi();
35
+ // => 'oe×ñÎ'
36
+ ```
37
+
38
+ ### Test Data
39
+
40
+ The package also exports test data that can be used for validation:
41
+
42
+ ```js
43
+ import { testGroups } from "tibetan-unicode-converter";
44
+
45
+ // testGroups is an array of test groups, each containing:
46
+ // - name: string
47
+ // - tests: array of { tibetan: string, conversion: string }
48
+ // - includeInPercentage?: boolean
49
+ // - sentences?: boolean
50
+ ```
51
+
52
+ ## Testing
53
+
54
+ ```bash
55
+ npm test
56
+ ```
57
+
58
+ ## Credits
59
+
60
+ A zillion thanks to:
61
+
62
+ - Tony Duff and friends for producing all these beautiful Tibetan fonts.
63
+
64
+ Through the virtue coming from this work, may all beings human and
65
+ otherwise reach absolute freedom.
66
+
67
+ ## License
68
+
69
+ This software is licensed under the MIT License.
70
+
71
+ Copyright Padmakara, 2021.
72
+
73
+ Permission is hereby granted, free of charge, to any person obtaining a
74
+ copy of this software and associated documentation files (the
75
+ "Software"), to deal in the Software without restriction, including
76
+ without limitation the rights to use, copy, modify, merge, publish,
77
+ distribute, sublicense, and/or sell copies of the Software, and to permit
78
+ persons to whom the Software is furnished to do so, subject to the
79
+ following conditions:
80
+
81
+ The above copyright notice and this permission notice shall be included
82
+ in all copies or substantial portions of the Software.
83
+
84
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
85
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
87
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
88
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
89
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
90
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { testGroups } from "./src/testGroups.js";
2
+ export {
3
+ default as TibetanUnicodeConverter,
4
+ default,
5
+ } from "./src/tibetan-unicode-converter.js";
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "tibetan-ansi-to-unicode",
3
+ "version": "1.1.0",
4
+ "description": "Convert between ANSI encoded Tibetan text and Unicode",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "module": "index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.js",
11
+ "require": "./index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "index.js",
16
+ "src"
17
+ ],
18
+ "scripts": {
19
+ "test": "node --test test/*.test.js"
20
+ },
21
+ "keywords": [
22
+ "tibetan",
23
+ "unicode",
24
+ "ansi",
25
+ "converter",
26
+ "text"
27
+ ],
28
+ "author": "Jeremy FRERE",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/jerefrer/tibetan-ansi-to-unicode.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/jerefrer/tibetan-ansi-to-unicode/issues"
36
+ },
37
+ "homepage": "https://github.com/jerefrer/tibetan-ansi-to-unicode#readme"
38
+ }
@@ -0,0 +1,311 @@
1
+ export const testGroups = [
2
+ {
3
+ name: "Alphabet with vowels",
4
+ tests: [
5
+ { tibetan: "ཀ", conversion: "!" },
6
+ { tibetan: "ཀི", conversion: "!Ü" },
7
+ { tibetan: "ཀུ", conversion: "!ß" },
8
+ { tibetan: "ཀེ", conversion: "!è" },
9
+ { tibetan: "ཀོ", conversion: "!ë" },
10
+ { tibetan: "ཁ", conversion: '"' },
11
+ { tibetan: "ཁི", conversion: '"Ü' },
12
+ { tibetan: "ཁུ", conversion: '"ß' },
13
+ { tibetan: "ཁེ", conversion: '"è' },
14
+ { tibetan: "ཁོ", conversion: '"ë' },
15
+ { tibetan: "ག", conversion: "#" },
16
+ { tibetan: "གི", conversion: "#Ü" },
17
+ { tibetan: "གུ", conversion: "#ß" },
18
+ { tibetan: "གེ", conversion: "#è" },
19
+ { tibetan: "གོ", conversion: "#ë" },
20
+ { tibetan: "ང", conversion: "$" },
21
+ { tibetan: "ངི", conversion: "$Ü" },
22
+ { tibetan: "ངུ", conversion: "$ß" },
23
+ { tibetan: "ངེ", conversion: "$è" },
24
+ { tibetan: "ངོ", conversion: "$ë" },
25
+ { tibetan: "ཅ", conversion: "%" },
26
+ { tibetan: "ཅི", conversion: "%Ü" },
27
+ { tibetan: "ཅུ", conversion: "%ß" },
28
+ { tibetan: "ཅེ", conversion: "%è" },
29
+ { tibetan: "ཅོ", conversion: "%ë" },
30
+ { tibetan: "ཆ", conversion: "&" },
31
+ { tibetan: "ཆི", conversion: "&Ü" },
32
+ { tibetan: "ཆུ", conversion: "&ß" },
33
+ { tibetan: "ཆེ", conversion: "&è" },
34
+ { tibetan: "ཆོ", conversion: "&ë" },
35
+ { tibetan: "ཇ", conversion: "'" },
36
+ { tibetan: "ཇི", conversion: "'Ü" },
37
+ { tibetan: "ཇུ", conversion: "'ß" },
38
+ { tibetan: "ཇེ", conversion: "'è" },
39
+ { tibetan: "ཇོ", conversion: "'ë" },
40
+ { tibetan: "ཉ", conversion: "(" },
41
+ { tibetan: "ཉི", conversion: "(Ü" },
42
+ { tibetan: "ཉུ", conversion: "(ß" },
43
+ { tibetan: "ཉེ", conversion: "(è" },
44
+ { tibetan: "ཉོ", conversion: "(ë" },
45
+ { tibetan: "ཏ", conversion: ")" },
46
+ { tibetan: "ཏི", conversion: ")Ü" },
47
+ { tibetan: "ཏུ", conversion: ")ß" },
48
+ { tibetan: "ཏེ", conversion: ")è" },
49
+ { tibetan: "ཏོ", conversion: ")ë" },
50
+ { tibetan: "ཐ", conversion: "*" },
51
+ { tibetan: "ཐི", conversion: "*Ü" },
52
+ { tibetan: "ཐུ", conversion: "*ß" },
53
+ { tibetan: "ཐེ", conversion: "*è" },
54
+ { tibetan: "ཐོ", conversion: "*ë" },
55
+ { tibetan: "ད", conversion: "+" },
56
+ { tibetan: "དི", conversion: "+Ü" },
57
+ { tibetan: "དུ", conversion: "+ß" },
58
+ { tibetan: "དེ", conversion: "+è" },
59
+ { tibetan: "དོ", conversion: "+ë" },
60
+ { tibetan: "ན", conversion: "," },
61
+ { tibetan: "ནི", conversion: ",Ü" },
62
+ { tibetan: "ནུ", conversion: ",ß" },
63
+ { tibetan: "ནེ", conversion: ",è" },
64
+ { tibetan: "ནོ", conversion: ",ë" },
65
+ { tibetan: "པ", conversion: "ý" },
66
+ { tibetan: "པི", conversion: "ýÜ" },
67
+ { tibetan: "པུ", conversion: "ýß" },
68
+ { tibetan: "པེ", conversion: "ýè" },
69
+ { tibetan: "པོ", conversion: "ýë" },
70
+ { tibetan: "ཕ", conversion: "." },
71
+ { tibetan: "ཕི", conversion: ".Ü" },
72
+ { tibetan: "ཕུ", conversion: ".ß" },
73
+ { tibetan: "ཕེ", conversion: ".è" },
74
+ { tibetan: "ཕོ", conversion: ".ë" },
75
+ { tibetan: "བ", conversion: "/" },
76
+ { tibetan: "བི", conversion: "/Ü" },
77
+ { tibetan: "བུ", conversion: "/ß" },
78
+ { tibetan: "བེ", conversion: "/è" },
79
+ { tibetan: "བོ", conversion: "/ë" },
80
+ { tibetan: "མ", conversion: "0" },
81
+ { tibetan: "མི", conversion: "0Ü" },
82
+ { tibetan: "མུ", conversion: "0ß" },
83
+ { tibetan: "མེ", conversion: "0è" },
84
+ { tibetan: "མོ", conversion: "0ë" },
85
+ { tibetan: "ཙ", conversion: "1" },
86
+ { tibetan: "ཙི", conversion: "1Ü" },
87
+ { tibetan: "ཙུ", conversion: "1ß" },
88
+ { tibetan: "ཙེ", conversion: "1è" },
89
+ { tibetan: "ཙོ", conversion: "1ë" },
90
+ { tibetan: "ཚ", conversion: "2" },
91
+ { tibetan: "ཚི", conversion: "2Ü" },
92
+ { tibetan: "ཚུ", conversion: "2ß" },
93
+ { tibetan: "ཚེ", conversion: "2è" },
94
+ { tibetan: "ཚོ", conversion: "2ë" },
95
+ { tibetan: "ཛ", conversion: "3" },
96
+ { tibetan: "ཛི", conversion: "3Ü" },
97
+ { tibetan: "ཛུ", conversion: "3ß" },
98
+ { tibetan: "ཛེ", conversion: "3è" },
99
+ { tibetan: "ཛོ", conversion: "3ë" },
100
+ { tibetan: "ཝ", conversion: "4" },
101
+ { tibetan: "ཝི", conversion: "4Ü" },
102
+ { tibetan: "ཝུ", conversion: "4ß" },
103
+ { tibetan: "ཝེ", conversion: "4è" },
104
+ { tibetan: "ཝོ", conversion: "4ë" },
105
+ { tibetan: "ཞ", conversion: "5" },
106
+ { tibetan: "ཞི", conversion: "5Ü" },
107
+ { tibetan: "ཞུ", conversion: "5ß" },
108
+ { tibetan: "ཞེ", conversion: "5è" },
109
+ { tibetan: "ཞོ", conversion: "5ë" },
110
+ { tibetan: "ཟ", conversion: "6" },
111
+ { tibetan: "ཟི", conversion: "6Ü" },
112
+ { tibetan: "ཟུ", conversion: "6ß" },
113
+ { tibetan: "ཟེ", conversion: "6è" },
114
+ { tibetan: "ཟོ", conversion: "6ë" },
115
+ { tibetan: "འ", conversion: "7" },
116
+ { tibetan: "འི", conversion: "7Ü" },
117
+ { tibetan: "འུ", conversion: "7ß" },
118
+ { tibetan: "འེ", conversion: "7è" },
119
+ { tibetan: "འོ", conversion: "7ë" },
120
+ { tibetan: "ཡ", conversion: "8" },
121
+ { tibetan: "ཡི", conversion: "8Ü" },
122
+ { tibetan: "ཡུ", conversion: "8ß" },
123
+ { tibetan: "ཡེ", conversion: "8è" },
124
+ { tibetan: "ཡོ", conversion: "8ë" },
125
+ { tibetan: "ར", conversion: "9" },
126
+ { tibetan: "རི", conversion: "9Ü" },
127
+ { tibetan: "རུ", conversion: "9ß" },
128
+ { tibetan: "རེ", conversion: "9è" },
129
+ { tibetan: "རོ", conversion: "9ë" },
130
+ { tibetan: "ལ", conversion: ":" },
131
+ { tibetan: "ལི", conversion: ":Ü" },
132
+ { tibetan: "ལུ", conversion: ":ß" },
133
+ { tibetan: "ལེ", conversion: ":è" },
134
+ { tibetan: "ལོ", conversion: ":ë" },
135
+ { tibetan: "ཤ", conversion: ";" },
136
+ { tibetan: "ཤི", conversion: ";Ü" },
137
+ { tibetan: "ཤུ", conversion: ";ß" },
138
+ { tibetan: "ཤེ", conversion: ";è" },
139
+ { tibetan: "ཤོ", conversion: ";ë" },
140
+ { tibetan: "ས", conversion: "<" },
141
+ { tibetan: "སི", conversion: "<Ü" },
142
+ { tibetan: "སུ", conversion: "<ß" },
143
+ { tibetan: "སེ", conversion: "<è" },
144
+ { tibetan: "སོ", conversion: "<ë" },
145
+ { tibetan: "ཧ", conversion: "=" },
146
+ { tibetan: "ཧི", conversion: "=Ü" },
147
+ { tibetan: "ཧུ", conversion: "=ß" },
148
+ { tibetan: "ཧེ", conversion: "=è" },
149
+ { tibetan: "ཧོ", conversion: "=ë" },
150
+ { tibetan: "ཨ", conversion: ">" },
151
+ { tibetan: "ཨི", conversion: ">Ü" },
152
+ { tibetan: "ཨུ", conversion: ">ß" },
153
+ { tibetan: "ཨེ", conversion: ">è" },
154
+ { tibetan: "ཨོ", conversion: ">ë" },
155
+ ],
156
+ },
157
+ {
158
+ name: "Special characters",
159
+ tests: [
160
+ { tibetan: "༄༅", conversion: "É" },
161
+ { tibetan: "་", conversion: "Í" },
162
+ { tibetan: "།", conversion: "Ê" },
163
+ { tibetan: "༔", conversion: "Î" },
164
+ { tibetan: "ཛྲ", conversion: "‰" },
165
+ ],
166
+ },
167
+ {
168
+ name: "The Seven Diamond Verses",
169
+ includeInPercentage: true,
170
+ sentences: true,
171
+ tests: [
172
+ { tibetan: "ཧཱུྃ༔", conversion: "oe×ñÎ" },
173
+ {
174
+ tibetan: "ཨོ་རྒྱན་ཡུལ་གྱི་ནུབ་བྱང་མཚམས༔",
175
+ conversion: `>ë-{,-8ß:-bÜ-¹¥/-e$-020<Î`,
176
+ },
177
+ { tibetan: "པདྨ་གེ་སར་སྡོང་པོ་ལ༔", conversion: `ýV-#è-<9-Zë$-ýë-:Î` },
178
+ {
179
+ tibetan: "ཡ་མཚན་མཆོག་གི་དངོས་གྲུབ་བརྙེས༔",
180
+ conversion: `8-02,-0&ë#-#Ü-+$ë<-iá/-/Cè<Î`,
181
+ },
182
+ {
183
+ tibetan: "པདྨ་འབྱུང་གནས་ཞེས་སུ་གྲགས༔",
184
+ conversion: `ýV-7e³$-#,<-5è<-<ß-i#<Î`,
185
+ },
186
+ {
187
+ tibetan: "འཁོར་དུ་མཁའ་འགྲོ་མང་པོས་བསྐོར༔",
188
+ conversion: `7"ë9-¸¥-0"7-7ië-0$-ýë<-/Uë9Î`,
189
+ },
190
+ {
191
+ tibetan: "ཁྱེད་ཀྱི་རྗེས་སུ་བདག་བསྒྲུབ་ཀྱིས༔",
192
+ conversion: `aè+-\`Ü-Bè<-<ß-/+#-/…å/-\`Ü<Î`,
193
+ },
194
+ {
195
+ tibetan: "བྱིན་གྱིས་བརླབ་ཕྱིར་གཤེགས་སུ་གསོལ༔",
196
+ conversion: `eÜ,-bÜ<-/x/-dÜ9-#;è#<-<ß-#<ë:Î`,
197
+ },
198
+ { tibetan: "གུ་རུ་པདྨ་སིདྡྷི་ཧཱུྃ༔", conversion: `μ¥-9ß-ýV-<ÜKÜ-oe×ñÎ` },
199
+ ],
200
+ },
201
+ {
202
+ name: "Prayer of the Three Kayas",
203
+ includeInPercentage: true,
204
+ sentences: true,
205
+ tests: [
206
+ {
207
+ tibetan: "ཨེ་མ་ཧོཿ སྤྲོས་བྲལ་ཆོས་ཀྱི་དབྱིངས་ཀྱི་ཞིང་ཁམས་སུ༔",
208
+ conversion: `>è-0-=ëï ‡ë<-o:-&ë<-\`Ü-+eÜ$<-\`Ü-5Ü$-"0<-<ßÎ`,
209
+ },
210
+ {
211
+ tibetan: "ཆོས་ཉིད་དུས་གསུམ་སྐྱེ་འགགས་མེད་པའི་ངང་༔",
212
+ conversion: `&ë<-(Ü+-¸¥<-#<ß0-þè-7##<-0è+-ý7Ü-$$-Î`,
213
+ },
214
+ {
215
+ tibetan: "བྱ་བྲལ་ལྷུན་རྫོགས་བདེ་བ་ཆེན་པོའི་སྐུ༔",
216
+ conversion: `e-o:-T©,-Jë#<-/+è-/-&è,-ýë7Ü-U¨Î`,
217
+ },
218
+ {
219
+ tibetan: "ནམ་མཁའ་བཞིན་དུ་ཐུགས་རྗེ་ཕྱོགས་རིས་མེད༔",
220
+ conversion: `,0-0"7-/5Ü,-¸¥-*ß#<-Bè-dë#<-9Ü<-0è+Î`,
221
+ },
222
+ {
223
+ tibetan: "བླ་མ་ཆོས་ཀྱི་སྐུ་ལ་གསོལ་བ་འདེབས༔",
224
+ conversion: `v-0-&ë<-\`Ü-U¨-:-#<ë:-/-7+è/<Î`,
225
+ },
226
+ {
227
+ tibetan: "ཨོ་རྒྱན་པདྨ་འབྱུང་གནས་ལ་གསོལ་བ་འདེབས༔",
228
+ conversion: `>ë-{,-ýV-7e³$-#,<-:-#<ë:-/-7+è/<Î`,
229
+ },
230
+ {
231
+ tibetan: "བདེ་ཆེན་ལྷུན་གྱིས་གྲུབ་པའི་ཞིང་ཁམས་སུ༔",
232
+ conversion: `/+è-&è,-T©,-bÜ<-iá/-ý7Ü-5Ü$-"0<-<ßÎ`,
233
+ },
234
+ {
235
+ tibetan: "སྐུ་གསུང་ཐུགས་དང་ཡོན་ཏན་ཕྲིན་ལས་ཀྱི༔",
236
+ conversion: `U¨-#<ß$-*ß#<-+$-8ë,-),-nÜ,-:<-\`ÜÎ`,
237
+ },
238
+ {
239
+ tibetan: "ཡེ་ཤེས་ལྔ་ལྡན་བདེ་བར་གཤེགས་པའི་སྐུ༔",
240
+ conversion: `8è-;è<-M-Q,-/+è-/9-#;è#<-ý7Ü-U¨Î`,
241
+ },
242
+ {
243
+ tibetan: "ཐུགས་རྗེའི་བྱེ་བྲག་སྣ་ཚོགས་སོ་སོར་སྟོན༔",
244
+ conversion: `*ß#<-Bè7Ü-eè-o#-[-2ì#<-<ë-<ë9-Yë,Î`,
245
+ },
246
+ {
247
+ tibetan: "བླ་མ་ལོངས་སྤྱོད་རྫོགས་སྐུ་ལ་གསོལ་བ་འདེབས༔",
248
+ conversion: `v-0-:ë$<-₫ë+-Jë#<-Uß-:-#<ë:-/-7+è/<Î`,
249
+ },
250
+ {
251
+ tibetan: "མི་འབྱེད་འཇིག་རྟེན་དག་པའི་ཞིང་ཁམས་སུ༔",
252
+ conversion: `0Ü-7eè+-7'Ü#-Dè,-+#-ý7Ü-5Ü$-"0<-<ßÎ`,
253
+ },
254
+ {
255
+ tibetan: "ཐུགས་རྗེ་ཆེན་པོ་འགྲོ་བའི་དོན་ལ་བྱོན༔",
256
+ conversion: `*ß#<-Bè-&è,-ýë-7ië-/7Ü-+ë,-:-eë,Î`,
257
+ },
258
+ {
259
+ tibetan: "གང་ལ་གང་འདུལ་ཐབས་ཀྱིས་འགྲོ་དོན་མཛད༔",
260
+ conversion: `#$-:-#$-7¸¥:-*/<-\`Ü<-7ië-+ë,-03+Î`,
261
+ },
262
+ {
263
+ tibetan: "འདས་དང་མ་བྱོན་ད་ལྟ་དུས་གསུམ་གྱི༔",
264
+ conversion: `7+<-+$-0-eë,-+-P-¸¥<-#<ß0-μbÜÎ`,
265
+ },
266
+ {
267
+ tibetan: "བླ་མ་སྤྲུལ་པའི་སྐུ་ལ་གསོལ་བ་འདེབས༔",
268
+ conversion: `v-0-‡å:-ý7Ü-U¨-:-#<ë:-/-7+è/<Î`,
269
+ },
270
+ ],
271
+ },
272
+ {
273
+ name: "Praise to Manjushri",
274
+ includeInPercentage: true,
275
+ sentences: true,
276
+ tests: [
277
+ {
278
+ tibetan: "བློ་གྲོས་སྤོབས་པའི་སྣང་བ་སྩལ་དུ་གསོལ།། །།",
279
+ conversion: `vë-ië<-\\ë/<-ý7Ü-[$-/-_:-¸¥-#<ë:ÊÊ ÊÊ`,
280
+ },
281
+ ],
282
+ },
283
+ {
284
+ name: "Tashi Gyepa",
285
+ includeInPercentage: true,
286
+ sentences: true,
287
+ tests: [
288
+ { tibetan: "ༀ།", conversion: `>ùÊ` },
289
+ {
290
+ tibetan: "སྣང་སྲིད་རྣམ་དག་རང་བཞིན་ལྷུན་གྲུབ་པའི། །",
291
+ conversion: `[$-rÜ+-F0-+#-9$-/5Ü,-T©,-iá/-ý7ÜÊ Ê`,
292
+ },
293
+ {
294
+ tibetan: "བཀྲ་ཤིས་ཕྱོགས་བཅུའི་ཞིང་ན་བཞུགས་པ་ཡི། །",
295
+ conversion: `/g-;Ü<-dë#<-/%°7Ü-5Ü$-,-/º¥#<-ý-8ÜÊ Ê`,
296
+ },
297
+ {
298
+ tibetan: "སངས་རྒྱས་ཆོས་དང་དགེ་འདུན་འཕགས་པའི་ཚོགས། །",
299
+ conversion: `<$<-{<-&ë<-+$-+#è-7¸¥,-7.#<-ý7Ü-2ì#<Ê Ê`,
300
+ },
301
+ {
302
+ tibetan: "ཀུན་ལ་ཕྱག་འཚལ་བདག་ཅག་བཀྲ་ཤིས་ཤོག །",
303
+ conversion: `´¥,-:-d#-72:-/+#-%#-/g-;Ü<-;ë# Ê`,
304
+ },
305
+ {
306
+ tibetan: "བཀྲ་ཤིས་བདེ་ལེགས་ཕུན་སུམ་ཚོགས་པར་ཤོག",
307
+ conversion: `/g-;Ü<-/+è-:è#<-.ß,-<ß0-2ì#<-ý9-;ë#`,
308
+ },
309
+ ],
310
+ },
311
+ ];
@@ -0,0 +1,255 @@
1
+ var TibetanUnicodeConverter = function (conversion) {
2
+ return {
3
+ conversion: conversion,
4
+ line: "",
5
+ convert: function () {
6
+ var replaced = this.conversion;
7
+ wordsMap.forEach(function (word) {
8
+ replaced = replaced.replace(
9
+ new RegExp(word.encoded, "g"),
10
+ word.tibetan
11
+ );
12
+ });
13
+ var chars = replaced.split("");
14
+ var char;
15
+ while ((char = chars.shift())) {
16
+ this.line += this.convertChar(char);
17
+ }
18
+ return this.line;
19
+ },
20
+ convertChar: function (char) {
21
+ if (char == " ") return char;
22
+ var match = charsMap.find(function (object) {
23
+ return object.encoded.includes(char);
24
+ });
25
+ if (match) return match.tibetan;
26
+ else return char;
27
+ },
28
+ convertToAnsi: function () {
29
+ var replaced = this.conversion;
30
+
31
+ // Build a set of tibetan sequences that have a direct charsMap entry
32
+ var charsMapTibetans = {};
33
+ charsMap.forEach(function (mapping) {
34
+ charsMapTibetans[mapping.tibetan] = true;
35
+ });
36
+
37
+ // Replace words first, but skip if charsMap has a direct mapping
38
+ wordsMap.forEach(function (word) {
39
+ if (charsMapTibetans[word.tibetan]) return; // Skip, charsMap will handle it
40
+ replaced = replaced.replace(
41
+ new RegExp(word.tibetan, "g"),
42
+ word.encoded
43
+ );
44
+ });
45
+
46
+ // Sort charsMap by tibetan length descending to match longer sequences first
47
+ var sortedCharsMap = charsMap.slice().sort(function (a, b) {
48
+ return b.tibetan.length - a.tibetan.length;
49
+ });
50
+ // Replace each tibetan character/sequence with its encoded equivalent
51
+ sortedCharsMap.forEach(function (mapping) {
52
+ // Use first encoded character when multiple options exist
53
+ var firstEncoded = mapping.encoded[0];
54
+ replaced = replaced.replace(
55
+ new RegExp(mapping.tibetan, "g"),
56
+ firstEncoded
57
+ );
58
+ });
59
+ return replaced;
60
+ },
61
+ };
62
+ };
63
+
64
+ var charsMap = [
65
+ { tibetan: "༈", encoded: "Ì" },
66
+ { tibetan: "་", encoded: "-Í" },
67
+ { tibetan: "།", encoded: "ÊË" },
68
+ { tibetan: "༔", encoded: "Î" },
69
+ { tibetan: "ཿ", encoded: "ï" },
70
+ { tibetan: "༴", encoded: "Ï" },
71
+ { tibetan: "༄༅", encoded: "É" },
72
+ { tibetan: "༄", encoded: "Ò" },
73
+ { tibetan: "༅", encoded: "È" },
74
+ { tibetan: "ཛྲ", encoded: "‰" }, // Maybe སྨྲ is more frequent
75
+ { tibetan: "སྭ", encoded: "—" },
76
+ { tibetan: "གྲྭ", encoded: "™" },
77
+ { tibetan: "ཏྭ", encoded: "" },
78
+ { tibetan: "ཌ", encoded: "¬" },
79
+ { tibetan: "སྦ", encoded: "]" }, // Maybe also ངྒ, but can it be really?
80
+ { tibetan: "བྷ", encoded: "£" },
81
+ { tibetan: "ཥ", encoded: "®" },
82
+ { tibetan: "ཛྱ", encoded: "ˆ" },
83
+ { tibetan: "ཋ", encoded: "«" },
84
+ { tibetan: "ཀྵ", encoded: "¯" },
85
+ { tibetan: "རྟ", encoded: "½" },
86
+ { tibetan: "ཎྜ", encoded: "¼" },
87
+ { tibetan: "རྒྷ", encoded: "¾" },
88
+ { tibetan: "྄", encoded: "ü" },
89
+ { tibetan: "རྐ", encoded: "?" },
90
+ { tibetan: "ིཾ", encoded: "ó" },
91
+ { tibetan: "ཱུ", encoded: "Õ" },
92
+ { tibetan: "ཻཾ", encoded: "ø" },
93
+ { tibetan: "སྐྲ", encoded: "„" },
94
+ { tibetan: "ཛྭ", encoded: "Š" },
95
+ { tibetan: "ཧྱ", encoded: "ƒ" },
96
+ { tibetan: "རྒ", encoded: "@" },
97
+ { tibetan: "ྭ", encoded: "Ÿ" },
98
+ // { tibetan: "ཚྭ", encoded: "'" },
99
+ { tibetan: "ཁྭ", encoded: "‹" },
100
+ { tibetan: "ཤྭ", encoded: "–" },
101
+
102
+ { tibetan: "ི", encoded: "ÜÝÞ" },
103
+ { tibetan: "ུ", encoded: "ߥ©°àáâäã³±ç娲槦" },
104
+ { tibetan: "ེ", encoded: "èé" },
105
+ { tibetan: "ོ", encoded: "ëì" },
106
+ { tibetan: "ཱུ", encoded: "Ø" },
107
+ { tibetan: "ཾ", encoded: "î" },
108
+ { tibetan: "ྃ", encoded: "ñ" },
109
+ { tibetan: "ཱ", encoded: "¡¢Ó" },
110
+ { tibetan: "ཻ", encoded: "ê" },
111
+ { tibetan: "ཱུ", encoded: "Ù" },
112
+
113
+ { tibetan: "ཀ", encoded: "!´" },
114
+ { tibetan: "ཁ", encoded: '"' },
115
+ { tibetan: "ག", encoded: "#μ" },
116
+ { tibetan: "ང", encoded: "$" },
117
+ { tibetan: "ཅ", encoded: "%" },
118
+ { tibetan: "ཆ", encoded: "&" },
119
+ { tibetan: "ཇ", encoded: "'" },
120
+ { tibetan: "ཉ", encoded: "(¶" },
121
+ { tibetan: "ཏ", encoded: ")·" },
122
+ { tibetan: "ཐ", encoded: "*" },
123
+ { tibetan: "ད", encoded: "+¸" },
124
+ { tibetan: "ན", encoded: ",¹" },
125
+ { tibetan: "པ", encoded: "ý" },
126
+ { tibetan: "ཕ", encoded: "." },
127
+ { tibetan: "བ", encoded: "/" },
128
+ { tibetan: "མ", encoded: "0" },
129
+ { tibetan: "ཙ", encoded: "1" },
130
+ { tibetan: "ཚ", encoded: "2" },
131
+ { tibetan: "ཛ", encoded: "3" },
132
+ { tibetan: "ཝ", encoded: "4" },
133
+ { tibetan: "ཞ", encoded: "5º" },
134
+ { tibetan: "ཟ", encoded: "6" },
135
+ { tibetan: "འ", encoded: "7" },
136
+ { tibetan: "ཡ", encoded: "8" },
137
+ { tibetan: "ར", encoded: "9" },
138
+ { tibetan: "ལ", encoded: ":" },
139
+ { tibetan: "ཤ", encoded: ";»" },
140
+ { tibetan: "ས", encoded: "<" },
141
+ { tibetan: "ཧ", encoded: "=" },
142
+ { tibetan: "ཨ", encoded: ">" },
143
+
144
+ { tibetan: "༠", encoded: "¾" }, // Also taken by རྒྷ, careful !
145
+ { tibetan: "༡", encoded: "¿" },
146
+ { tibetan: "༢", encoded: "À" },
147
+ { tibetan: "༣", encoded: "Á" },
148
+ { tibetan: "༤", encoded: "Â" },
149
+ { tibetan: "༥", encoded: "Ã" },
150
+ { tibetan: "༦", encoded: "Ä" },
151
+ { tibetan: "༧", encoded: "Å" },
152
+ { tibetan: "༨", encoded: "Æ" },
153
+ { tibetan: "༩", encoded: "Ç" },
154
+
155
+ { tibetan: "ཊ", encoded: "ª" },
156
+
157
+ { tibetan: "ཁྱ", encoded: "a" },
158
+ { tibetan: "གྱ", encoded: "b" },
159
+ { tibetan: "པྱ", encoded: "c" },
160
+ { tibetan: "ཕྱ", encoded: "d" },
161
+ { tibetan: "བྱ", encoded: "e" },
162
+ { tibetan: "མྱ", encoded: "f" },
163
+ { tibetan: "ཀྲ", encoded: "g" },
164
+ { tibetan: "ཁྲ", encoded: "h" },
165
+ { tibetan: "གྲ", encoded: "i" },
166
+ { tibetan: "ཏྲ", encoded: "j" },
167
+ { tibetan: "ཐྲ", encoded: "k" },
168
+ { tibetan: "དྲ", encoded: "l" },
169
+ { tibetan: "པྲ", encoded: "m" },
170
+ { tibetan: "ཕྲ", encoded: "n" },
171
+ { tibetan: "བྲ", encoded: "o" },
172
+ { tibetan: "མྲ", encoded: "p" },
173
+ { tibetan: "ཤྲ", encoded: "q" },
174
+ { tibetan: "སྲ", encoded: "r" },
175
+ { tibetan: "ཧྲ", encoded: "s" },
176
+ { tibetan: "ཀླ", encoded: "t" },
177
+ { tibetan: "གླ", encoded: "u" },
178
+ { tibetan: "བླ", encoded: "v" },
179
+ { tibetan: "ཟླ", encoded: "w" },
180
+ { tibetan: "རླ", encoded: "x" },
181
+ { tibetan: "སླ", encoded: "y" },
182
+ { tibetan: "རྐྱ", encoded: "z" },
183
+ { tibetan: "རྔ", encoded: "A" },
184
+ { tibetan: "རྗ", encoded: "B" },
185
+ { tibetan: "རྙ", encoded: "C" },
186
+ { tibetan: "རྟ", encoded: "D" },
187
+ { tibetan: "རྡ", encoded: "E" },
188
+ { tibetan: "རྣ", encoded: "F" },
189
+ { tibetan: "རྦ", encoded: "G" },
190
+ { tibetan: "རྨ", encoded: "H" },
191
+ { tibetan: "རྩ", encoded: "I" },
192
+ { tibetan: "རྫ", encoded: "J" },
193
+ { tibetan: "ལྐ", encoded: "K" },
194
+ { tibetan: "ལྒ", encoded: "L" },
195
+ { tibetan: "ལྔ", encoded: "M" },
196
+ { tibetan: "ལྕ", encoded: "N" },
197
+ { tibetan: "ལྗ", encoded: "O" },
198
+ { tibetan: "ལྟ", encoded: "P" },
199
+ { tibetan: "ལྡ", encoded: "Q" },
200
+ { tibetan: "ལྤ", encoded: "R" },
201
+ { tibetan: "ལྦ", encoded: "S" },
202
+ { tibetan: "ལྷ", encoded: "T" },
203
+ { tibetan: "སྐ", encoded: "U" },
204
+ { tibetan: "སྒ", encoded: "V" },
205
+ { tibetan: "སྔ", encoded: "W" },
206
+ { tibetan: "སྤ", encoded: "\\" },
207
+ { tibetan: "སྙ", encoded: "X" },
208
+ { tibetan: "སྟ", encoded: "Y" },
209
+ { tibetan: "སྡ", encoded: "Z" },
210
+ { tibetan: "སྒྲ", encoded: "…" },
211
+ { tibetan: "སྣ", encoded: "[" },
212
+ { tibetan: "ཀྱ", encoded: "`" },
213
+ { tibetan: "རྒྱ", encoded: "{" },
214
+ { tibetan: "སྤྱ", encoded: "₫" },
215
+ { tibetan: "སྐྱ", encoded: "þ" },
216
+ { tibetan: "སྒྱ", encoded: "€" },
217
+ { tibetan: "སྤྲ", encoded: "‡" },
218
+ { tibetan: "སྦྱ", encoded: "‚" },
219
+ { tibetan: "སྤྱ", encoded: "" },
220
+ { tibetan: "སྨ", encoded: "^" },
221
+ { tibetan: "སྩ", encoded: "_" },
222
+ { tibetan: "ཏྭ", encoded: "₮" },
223
+ { tibetan: "དྭ", encoded: "₯" },
224
+ { tibetan: "དྲྭ", encoded: "š" },
225
+ { tibetan: "༼", encoded: "Ð" },
226
+ { tibetan: "༽", encoded: "Ñ" },
227
+ ];
228
+
229
+ var wordsMap = [
230
+ { tibetan: "གྱ", encoded: "μb" },
231
+ { tibetan: "ཧཱུྃ", encoded: "oe×ñ" },
232
+ { tibetan: "སིདྡྷི", encoded: "<ÜKÜ" },
233
+ { tibetan: "སིདྡྷི", encoded: "<Ü-KÜ" },
234
+ { tibetan: "པདྨ", encoded: "ýV" },
235
+ { tibetan: "ཏྤལ", encoded: ",:" },
236
+ { tibetan: "ༀ", encoded: ">ù" },
237
+ { tibetan: "ཊྭཱཾ", encoded: "¤Êî" },
238
+ { tibetan: "ཊྭ", encoded: "¤" },
239
+ { tibetan: "ཧཱ", encoded: "¼Ô" },
240
+ { tibetan: "སམྦྷ", encoded: "<0-£" },
241
+ { tibetan: "ཞྭ", encoded: "\u201C" },
242
+ { tibetan: "པཎ", encoded: "ýC" },
243
+ { tibetan: "བྷ་ནྡྷ", encoded: "£v" },
244
+ { tibetan: "ཌཱུརྻ", encoded: "¬Ù<" },
245
+ { tibetan: "ཌཱུརྻ", encoded: "¬Ù4" },
246
+ { tibetan: "བྷྲཱུྃ", encoded: "¨Ôñ" },
247
+ { tibetan: "ཛྙཱ", encoded: "ƒÉ" },
248
+ { tibetan: "དིཔྟ", encoded: "\\+ÜŠ" },
249
+ { tibetan: "ཤཱུ་ནྱ", encoded: "»Õ-‚" },
250
+ { tibetan: "ཏཱ", encoded: "·Ô" },
251
+ { tibetan: "ཨོཾཿ", encoded: ">ùï" },
252
+ { tibetan: "མངྒ་ལཾ", encoded: "0]-:î" },
253
+ ];
254
+
255
+ export default TibetanUnicodeConverter;