1 | "use strict"; |
||
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
||
3 | return new (P || (P = Promise))(function (resolve, reject) { |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
||
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
||
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } |
||
7 | step((generator = generator.apply(thisArg, _arguments || [])).next()); |
||
8 | }); |
||
9 | }; |
||
10 | Object.defineProperty(exports, "__esModule", { value: true }); |
||
11 | const testerID = 'fontTester'; |
||
12 | let browserFont; |
||
13 | const addTestDivToBody = () => { |
||
14 | const newDiv = document.createElement('div'); |
||
15 | newDiv.style.cssText = |
||
16 | 'position:absolute;width:100%;opacity:0.3;z-index:-10; top: -50px; height: 20px; display: none'; |
||
17 | newDiv.id = testerID; |
||
18 | const spanCss = 'font-family: initial; margin: 0; padding: 0; font-size: 20px; line-height: 20px; height: 20px;'; |
||
19 | const testSpans = '<span style="' + |
||
20 | spanCss + |
||
21 | '" id="one_ka">က</span>\n' + |
||
22 | '<span style="' + |
||
23 | spanCss + |
||
24 | '" id="two_ka">က္က</span>\n'; |
||
25 | newDiv.innerHTML = testSpans; |
||
26 | document.body.appendChild(newDiv); |
||
27 | return true; |
||
28 | }; |
||
29 | const detectBrowserFont = () => { |
||
30 | const testDiv = document.getElementById(testerID); |
||
31 | if (testDiv) { |
||
32 | testDiv.style.display = ''; |
||
33 | } |
||
34 | const oneKa = document.getElementById('one_ka'); |
||
35 | const twoKa = document.getElementById('two_ka'); |
||
36 | if (oneKa && twoKa) { |
||
37 | browserFont = oneKa.offsetWidth * 1.5 > twoKa.offsetWidth ? 'Unicode' : 'Zawgyi'; |
||
38 | if (testDiv) { |
||
39 | testDiv.style.display = 'none'; |
||
40 | } |
||
41 | } |
||
42 | return browserFont; |
||
0 ignored issues
–
show
|
|||
43 | }; |
||
44 | const init = () => __awaiter(this, void 0, void 0, function* () { |
||
0 ignored issues
–
show
|
|||
45 | if (document.getElementById(testerID)) { |
||
46 | browserFont = detectBrowserFont(); |
||
47 | } |
||
48 | else { |
||
49 | yield addTestDivToBody(); |
||
50 | browserFont = detectBrowserFont(); |
||
51 | } |
||
52 | }); |
||
53 | init(); |
||
54 | const replaceWithRule = (rule, output) => { |
||
55 | const maxLoop = rule.length; |
||
56 | for (let i = 0; i < maxLoop; i++) { |
||
57 | const data = rule[i]; |
||
58 | const from = data.from; |
||
59 | const to = data.to; |
||
60 | const fromRegex = new RegExp(from, 'g'); |
||
61 | output = output.replace(fromRegex, to); |
||
62 | } |
||
63 | return output; |
||
64 | }; |
||
65 | exports.getBrowserFont = () => { |
||
66 | return browserFont; |
||
67 | }; |
||
68 | exports.isMyanmarText = (text) => { |
||
69 | const MyanmarReg = new RegExp('[\u1000-\u1021]'); |
||
70 | return MyanmarReg.test(text) ? true : false; |
||
71 | }; |
||
72 | exports.uni2zg = (output) => { |
||
73 | if (!exports.isMyanmarText(output)) { |
||
74 | return output; |
||
75 | } |
||
76 | const rule = [ |
||
77 | { |
||
78 | from: '\u1004\u103a\u1039', |
||
79 | to: '\u1064', |
||
80 | }, |
||
81 | { |
||
82 | from: '\u1039\u1010\u103d', |
||
83 | to: '\u1096', |
||
84 | }, |
||
85 | { |
||
86 | from: '\u102b\u103a', |
||
87 | to: '\u105a', |
||
88 | }, |
||
89 | { |
||
90 | from: '\u100b\u1039\u100c', |
||
91 | to: '\u1092', |
||
92 | }, |
||
93 | { |
||
94 | from: '\u102d\u1036', |
||
95 | to: '\u108e', |
||
96 | }, |
||
97 | { |
||
98 | from: '\u104e\u1004\u103a\u1038', |
||
99 | to: '\u104e', |
||
100 | }, |
||
101 | { |
||
102 | from: '[\u1025\u1009](?=[\u1039\u102f\u1030])', |
||
103 | to: '\u106a', |
||
104 | }, |
||
105 | { |
||
106 | from: '[\u1025\u1009](?=[\u1037]?[\u103a])', |
||
107 | to: '\u1025', |
||
108 | }, |
||
109 | { |
||
110 | from: '\u100a(?=[\u1039\u103d])', |
||
111 | to: '\u106b', |
||
112 | }, |
||
113 | { |
||
114 | from: '(\u1039[\u1000-\u1021])(\u102D){0,1}\u102f', |
||
115 | to: '$1$2\u1033', |
||
116 | }, |
||
117 | { |
||
118 | from: '(\u1039[\u1000-\u1021])\u1030', |
||
119 | to: '$1\u1034', |
||
120 | }, |
||
121 | { |
||
122 | from: '\u1014(?=[\u102d\u102e\u103a]?[\u102f\u1030\u103d\u103e\u1039])', |
||
123 | to: '\u108f', |
||
124 | }, |
||
125 | { |
||
126 | from: '\u1014\u103c', |
||
127 | to: '\u108f\u103c', |
||
128 | }, |
||
129 | { |
||
130 | from: '\u1039\u1000', |
||
131 | to: '\u1060', |
||
132 | }, |
||
133 | { |
||
134 | from: '\u1039\u1001', |
||
135 | to: '\u1061', |
||
136 | }, |
||
137 | { |
||
138 | from: '\u1039\u1002', |
||
139 | to: '\u1062', |
||
140 | }, |
||
141 | { |
||
142 | from: '\u1039\u1003', |
||
143 | to: '\u1063', |
||
144 | }, |
||
145 | { |
||
146 | from: '\u1039\u1005', |
||
147 | to: '\u1065', |
||
148 | }, |
||
149 | { |
||
150 | from: '\u1039\u1006', |
||
151 | to: '\u1066', |
||
152 | }, |
||
153 | { |
||
154 | from: '\u1039\u1007', |
||
155 | to: '\u1068', |
||
156 | }, |
||
157 | { |
||
158 | from: '\u1039\u1008', |
||
159 | to: '\u1069', |
||
160 | }, |
||
161 | { |
||
162 | from: '\u1039\u100b', |
||
163 | to: '\u106c', |
||
164 | }, |
||
165 | { |
||
166 | from: '\u1039\u100c', |
||
167 | to: '\u106d', |
||
168 | }, |
||
169 | { |
||
170 | from: '\u100d\u1039\u100d', |
||
171 | to: '\u106e', |
||
172 | }, |
||
173 | { |
||
174 | from: '\u100e\u1039\u100d', |
||
175 | to: '\u106f', |
||
176 | }, |
||
177 | { |
||
178 | from: '\u1039\u100f', |
||
179 | to: '\u1070', |
||
180 | }, |
||
181 | { |
||
182 | from: '\u1039\u1010', |
||
183 | to: '\u1071', |
||
184 | }, |
||
185 | { |
||
186 | from: '\u1039\u1011', |
||
187 | to: '\u1073', |
||
188 | }, |
||
189 | { |
||
190 | from: '\u1039\u1012', |
||
191 | to: '\u1075', |
||
192 | }, |
||
193 | { |
||
194 | from: '\u1039\u1013', |
||
195 | to: '\u1076', |
||
196 | }, |
||
197 | { |
||
198 | from: '\u1039[\u1014\u108f]', |
||
199 | to: '\u1077', |
||
200 | }, |
||
201 | { |
||
202 | from: '\u1039\u1015', |
||
203 | to: '\u1078', |
||
204 | }, |
||
205 | { |
||
206 | from: '\u1039\u1016', |
||
207 | to: '\u1079', |
||
208 | }, |
||
209 | { |
||
210 | from: '\u1039\u1017', |
||
211 | to: '\u107a', |
||
212 | }, |
||
213 | { |
||
214 | from: '\u1039\u1018', |
||
215 | to: '\u107b', |
||
216 | }, |
||
217 | { |
||
218 | from: '\u1039\u1019', |
||
219 | to: '\u107c', |
||
220 | }, |
||
221 | { |
||
222 | from: '\u1039\u101c', |
||
223 | to: '\u1085', |
||
224 | }, |
||
225 | { |
||
226 | from: '\u103f', |
||
227 | to: '\u1086', |
||
228 | }, |
||
229 | { |
||
230 | from: '\u103d\u103e', |
||
231 | to: '\u108a', |
||
232 | }, |
||
233 | { |
||
234 | from: '(\u1064)([\u1000-\u1021])([\u103b\u103c]?)\u102d', |
||
235 | to: '$2$3\u108b', |
||
236 | }, |
||
237 | { |
||
238 | from: '(\u1064)([\u1000-\u1021])([\u103b\u103c]?)\u102e', |
||
239 | to: '$2$3\u108c', |
||
240 | }, |
||
241 | { |
||
242 | from: '(\u1064)([\u1000-\u1021])([\u103b\u103c]?)\u1036', |
||
243 | to: '$2$3\u108d', |
||
244 | }, |
||
245 | { |
||
246 | from: '(\u1064)([\u1000-\u1021])([\u103b\u103c]?)([\u1031]?)', |
||
247 | to: '$2$3$4$1', |
||
248 | }, |
||
249 | { |
||
250 | from: '\u101b(?=([\u102d\u102e]?)[\u102f\u1030\u103d\u108a])', |
||
251 | to: '\u1090', |
||
252 | }, |
||
253 | { |
||
254 | from: '\u100f\u1039\u100d', |
||
255 | to: '\u1091', |
||
256 | }, |
||
257 | { |
||
258 | from: '\u100b\u1039\u100b', |
||
259 | to: '\u1097', |
||
260 | }, |
||
261 | { |
||
262 | from: '([\u1000-\u1021\u108f\u1029\u1090])([\u1060-\u1069\u106c\u106d\u1070-\u107c\u1085\u108a])?([\u103b-\u103e]*)?\u1031', |
||
263 | to: '\u1031$1$2$3', |
||
264 | }, |
||
265 | { |
||
266 | from: '\u103c\u103e', |
||
267 | to: '\u103c\u1087', |
||
268 | }, |
||
269 | { |
||
270 | from: '([\u1000-\u1021\u108f\u1029])([\u1060-\u1069\u106c\u106d\u1070-\u107c\u1085])?(\u103c)', |
||
271 | to: '$3$1$2', |
||
272 | }, |
||
273 | { |
||
274 | from: '\u103a', |
||
275 | to: '\u1039', |
||
276 | }, |
||
277 | { |
||
278 | from: '\u103b', |
||
279 | to: '\u103a', |
||
280 | }, |
||
281 | { |
||
282 | from: '\u103c', |
||
283 | to: '\u103b', |
||
284 | }, |
||
285 | { |
||
286 | from: '\u103d', |
||
287 | to: '\u103c', |
||
288 | }, |
||
289 | { |
||
290 | from: '\u103e', |
||
291 | to: '\u103d', |
||
292 | }, |
||
293 | { |
||
294 | from: '([^\u103a\u100a])\u103d([\u102d\u102e]?)\u102f', |
||
295 | to: '$1\u1088$2', |
||
296 | }, |
||
297 | { |
||
298 | from: '([\u101b\u103a\u103c\u108a\u1088\u1090])([\u1030\u103d])?([\u1032\u1036\u1039\u102d\u102e\u108b\u108c\u108d\u108e]?)(\u102f)?\u1037', |
||
299 | to: '$1$2$3$4\u1095', |
||
300 | }, |
||
301 | { |
||
302 | from: '([\u102f\u1014\u1030\u103d])([\u1032\u1036\u1039\u102d\u102e\u108b\u108c\u108d\u108e]?)\u1037', |
||
303 | to: '$1$2\u1094', |
||
304 | }, |
||
305 | { |
||
306 | from: '([\u103b])([\u1000-\u1021])([\u1087]?)([\u1036\u102d\u102e\u108b\u108c\u108d\u108e]?)\u102f', |
||
307 | to: '$1$2$3$4\u1033', |
||
308 | }, |
||
309 | { |
||
310 | from: '([\u103b])([\u1000-\u1021])([\u1087]?)([\u1036\u102d\u102e\u108b\u108c\u108d\u108e]?)\u1030', |
||
311 | to: '$1$2$3$4\u1034', |
||
312 | }, |
||
313 | { |
||
314 | from: '([\u103a\u103c\u100a\u1020\u1025])([\u103d]?)([\u1036\u102d\u102e\u108b\u108c\u108d\u108e]?)\u102f', |
||
315 | to: '$1$2$3\u1033', |
||
316 | }, |
||
317 | { |
||
318 | from: '([\u103a\u103c\u100a\u101b])(\u103d?)([\u1036\u102d\u102e\u108b\u108c\u108d\u108e]?)\u1030', |
||
319 | to: '$1$2$3\u1034', |
||
320 | }, |
||
321 | { |
||
322 | from: '\u100a\u103d', |
||
323 | to: '\u100a\u1087', |
||
324 | }, |
||
325 | { |
||
326 | from: '\u103d\u1030', |
||
327 | to: '\u1089', |
||
328 | }, |
||
329 | { |
||
330 | from: '\u103b([\u1000\u1003\u1006\u100f\u1010\u1011\u1018\u101a\u101c\u101a\u101e\u101f])', |
||
331 | to: '\u107e$1', |
||
332 | }, |
||
333 | { |
||
334 | from: '\u107e([\u1000\u1003\u1006\u100f\u1010\u1011\u1018\u101a\u101c\u101a\u101e\u101f])([\u103c\u108a])([\u1032\u1036\u102d\u102e\u108b\u108c\u108d\u108e])', |
||
335 | to: '\u1084$1$2$3', |
||
336 | }, |
||
337 | { |
||
338 | from: '\u107e([\u1000\u1003\u1006\u100f\u1010\u1011\u1018\u101a\u101c\u101a\u101e\u101f])([\u103c\u108a])', |
||
339 | to: '\u1082$1$2', |
||
340 | }, |
||
341 | { |
||
342 | from: '\u107e([\u1000\u1003\u1006\u100f\u1010\u1011\u1018\u101a\u101c\u101a\u101e\u101f])([\u1033\u1034]?)([\u1032\u1036\u102d\u102e\u108b\u108c\u108d\u108e])', |
||
343 | to: '\u1080$1$2$3', |
||
344 | }, |
||
345 | { |
||
346 | from: '\u103b([\u1000-\u1021])([\u103c\u108a])([\u1032\u1036\u102d\u102e\u108b\u108c\u108d\u108e])', |
||
347 | to: '\u1083$1$2$3', |
||
348 | }, |
||
349 | { |
||
350 | from: '\u103b([\u1000-\u1021])([\u103c\u108a])', |
||
351 | to: '\u1081$1$2', |
||
352 | }, |
||
353 | { |
||
354 | from: '\u103b([\u1000-\u1021])([\u1033\u1034]?)([\u1032\u1036\u102d\u102e\u108b\u108c\u108d\u108e])', |
||
355 | to: '\u107f$1$2$3', |
||
356 | }, |
||
357 | { |
||
358 | from: '\u103a\u103d', |
||
359 | to: '\u103d\u103a', |
||
360 | }, |
||
361 | { |
||
362 | from: '\u103a([\u103c\u108a])', |
||
363 | to: '$1\u107d', |
||
364 | }, |
||
365 | { |
||
366 | from: '([\u1033\u1034])(\u1036?)\u1094', |
||
367 | to: '$1$2\u1095', |
||
368 | }, |
||
369 | { |
||
370 | from: '\u108F\u1071', |
||
371 | to: '\u108F\u1072', |
||
372 | }, |
||
373 | { |
||
374 | from: '([\u1000-\u1021])([\u107B\u1066])\u102C', |
||
375 | to: '$1\u102C$2', |
||
376 | }, |
||
377 | { |
||
378 | from: '\u102C([\u107B\u1066])\u1037', |
||
379 | to: '\u102C$1\u1094', |
||
380 | }, |
||
381 | ]; |
||
382 | return replaceWithRule(rule, output); |
||
383 | }; |
||
384 | exports.zg2uni = (output) => { |
||
385 | if (!exports.isMyanmarText(output)) { |
||
386 | return output; |
||
387 | } |
||
388 | const rule = [ |
||
389 | { |
||
390 | from: '\u102f\u102f', |
||
391 | to: '\u102f', |
||
392 | }, |
||
393 | { |
||
394 | from: '\u200B', |
||
395 | to: '', |
||
396 | }, |
||
397 | { |
||
398 | from: '(\u103d|\u1087)', |
||
399 | to: '\u103e', |
||
400 | }, |
||
401 | { |
||
402 | from: '\u103c', |
||
403 | to: '\u103d', |
||
404 | }, |
||
405 | { |
||
406 | from: '(\u103b|\u107e|\u107f|\u1080|\u1081|\u1082|\u1083|\u1084)', |
||
407 | to: '\u103c', |
||
408 | }, |
||
409 | { |
||
410 | from: '(\u103a|\u107d)', |
||
411 | to: '\u103b', |
||
412 | }, |
||
413 | { |
||
414 | from: '\u1039', |
||
415 | to: '\u103a', |
||
416 | }, |
||
417 | { |
||
418 | from: '(\u1066|\u1067)', |
||
419 | to: '\u1039\u1006', |
||
420 | }, |
||
421 | { |
||
422 | from: '\u106a', |
||
423 | to: '\u1009', |
||
424 | }, |
||
425 | { |
||
426 | from: '\u106b', |
||
427 | to: '\u100a', |
||
428 | }, |
||
429 | { |
||
430 | from: '\u106c', |
||
431 | to: '\u1039\u100b', |
||
432 | }, |
||
433 | { |
||
434 | from: '\u106d', |
||
435 | to: '\u1039\u100c', |
||
436 | }, |
||
437 | { |
||
438 | from: '\u106e', |
||
439 | to: '\u100d\u1039\u100d', |
||
440 | }, |
||
441 | { |
||
442 | from: '\u106f', |
||
443 | to: '\u100d\u1039\u100e', |
||
444 | }, |
||
445 | { |
||
446 | from: '\u1070', |
||
447 | to: '\u1039\u100f', |
||
448 | }, |
||
449 | { |
||
450 | from: '(\u1071|\u1072)', |
||
451 | to: '\u1039\u1010', |
||
452 | }, |
||
453 | { |
||
454 | from: '\u1060', |
||
455 | to: '\u1039\u1000', |
||
456 | }, |
||
457 | { |
||
458 | from: '\u1061', |
||
459 | to: '\u1039\u1001', |
||
460 | }, |
||
461 | { |
||
462 | from: '\u1062', |
||
463 | to: '\u1039\u1002', |
||
464 | }, |
||
465 | { |
||
466 | from: '\u1063', |
||
467 | to: '\u1039\u1003', |
||
468 | }, |
||
469 | { |
||
470 | from: '\u1065', |
||
471 | to: '\u1039\u1005', |
||
472 | }, |
||
473 | { |
||
474 | from: '\u1068', |
||
475 | to: '\u1039\u1007', |
||
476 | }, |
||
477 | { |
||
478 | from: '\u1069', |
||
479 | to: '\u1039\u1008', |
||
480 | }, |
||
481 | { |
||
482 | from: '(\u1073|\u1074)', |
||
483 | to: '\u1039\u1011', |
||
484 | }, |
||
485 | { |
||
486 | from: '\u1075', |
||
487 | to: '\u1039\u1012', |
||
488 | }, |
||
489 | { |
||
490 | from: '\u1076', |
||
491 | to: '\u1039\u1013', |
||
492 | }, |
||
493 | { |
||
494 | from: '\u1077', |
||
495 | to: '\u1039\u1014', |
||
496 | }, |
||
497 | { |
||
498 | from: '\u1078', |
||
499 | to: '\u1039\u1015', |
||
500 | }, |
||
501 | { |
||
502 | from: '\u1079', |
||
503 | to: '\u1039\u1016', |
||
504 | }, |
||
505 | { |
||
506 | from: '\u107a', |
||
507 | to: '\u1039\u1017', |
||
508 | }, |
||
509 | { |
||
510 | from: '\u107c', |
||
511 | to: '\u1039\u1019', |
||
512 | }, |
||
513 | { |
||
514 | from: '\u1085', |
||
515 | to: '\u1039\u101c', |
||
516 | }, |
||
517 | { |
||
518 | from: '\u1033', |
||
519 | to: '\u102f', |
||
520 | }, |
||
521 | { |
||
522 | from: '\u1034', |
||
523 | to: '\u1030', |
||
524 | }, |
||
525 | { |
||
526 | from: '\u103f', |
||
527 | to: '\u1030', |
||
528 | }, |
||
529 | { |
||
530 | from: '\u1086', |
||
531 | to: '\u103f', |
||
532 | }, |
||
533 | { |
||
534 | from: '\u1036\u1088', |
||
535 | to: '\u1088\u1036', |
||
536 | }, |
||
537 | { |
||
538 | from: '\u1088', |
||
539 | to: '\u103e\u102f', |
||
540 | }, |
||
541 | { |
||
542 | from: '\u1089', |
||
543 | to: '\u103e\u1030', |
||
544 | }, |
||
545 | { |
||
546 | from: '\u108a', |
||
547 | to: '\u103d\u103e', |
||
548 | }, |
||
549 | { |
||
550 | from: '\u103B\u1064', |
||
551 | to: '\u1064\u103B', |
||
552 | }, |
||
553 | { |
||
554 | from: '(\u1031)?([\u1000-\u1021])\u1064', |
||
555 | to: '\u1004\u103a\u1039$1$2', |
||
556 | }, |
||
557 | { |
||
558 | from: '(\u1031)?([\u1000-\u1021])\u108b', |
||
559 | to: '\u1004\u103a\u1039$1$2\u102d', |
||
560 | }, |
||
561 | { |
||
562 | from: '(\u1031)?([\u1000-\u1021])\u108c', |
||
563 | to: '\u1004\u103a\u1039$1$2\u102e', |
||
564 | }, |
||
565 | { |
||
566 | from: '(\u1031)?([\u1000-\u1021])\u108d', |
||
567 | to: '\u1004\u103a\u1039$1$2\u1036', |
||
568 | }, |
||
569 | { |
||
570 | from: '\u108e', |
||
571 | to: '\u102d\u1036', |
||
572 | }, |
||
573 | { |
||
574 | from: '\u108f', |
||
575 | to: '\u1014', |
||
576 | }, |
||
577 | { |
||
578 | from: '\u1090', |
||
579 | to: '\u101b', |
||
580 | }, |
||
581 | { |
||
582 | from: '\u1091', |
||
583 | to: '\u100f\u1039\u100d', |
||
584 | }, |
||
585 | { |
||
586 | from: '\u1019\u102c(\u107b|\u1093)', |
||
587 | to: '\u1019\u1039\u1018\u102c', |
||
588 | }, |
||
589 | { |
||
590 | from: '(\u107b|\u1093)', |
||
591 | to: '\u1039\u1018', |
||
592 | }, |
||
593 | { |
||
594 | from: '(\u1094|\u1095)', |
||
595 | to: '\u1037', |
||
596 | }, |
||
597 | { |
||
598 | from: '([\u1000-\u1021])\u1037\u1032', |
||
599 | to: '$1\u1032\u1037', |
||
600 | }, |
||
601 | { |
||
602 | from: '\u1096', |
||
603 | to: '\u1039\u1010\u103d', |
||
604 | }, |
||
605 | { |
||
606 | from: '\u1097', |
||
607 | to: '\u100b\u1039\u100b', |
||
608 | }, |
||
609 | { |
||
610 | from: '\u103c([\u1000-\u1021])([\u1000-\u1021])?', |
||
611 | to: '$1\u103c$2', |
||
612 | }, |
||
613 | { |
||
614 | from: '([\u1000-\u1021])\u103c\u103a', |
||
615 | to: '\u103c$1\u103a', |
||
616 | }, |
||
617 | { |
||
618 | from: '\u1047(?=[\u102c-\u1030\u1032\u1036-\u1038\u103d\u1038])', |
||
619 | to: '\u101b', |
||
620 | }, |
||
621 | { |
||
622 | from: '\u1031\u1047', |
||
623 | to: '\u1031\u101b', |
||
624 | }, |
||
625 | { |
||
626 | from: '\u1040(\u102e|\u102f|\u102d\u102f|\u1030|\u1036|\u103d|\u103e)', |
||
627 | to: '\u101d$1', |
||
628 | }, |
||
629 | { |
||
630 | from: '([^\u1040\u1041\u1042\u1043\u1044\u1045\u1046\u1047\u1048\u1049])\u1040\u102b', |
||
631 | to: '$1\u101d\u102b', |
||
632 | }, |
||
633 | { |
||
634 | from: '([\u1040\u1041\u1042\u1043\u1044\u1045\u1046\u1047\u1048\u1049])\u1040\u102b(?!\u1038)', |
||
635 | to: '$1\u101d\u102b', |
||
636 | }, |
||
637 | { |
||
638 | from: '^\u1040(?=\u102b)', |
||
639 | to: '\u101d', |
||
640 | }, |
||
641 | { |
||
642 | from: '\u1040\u102d(?!\u0020?/)', |
||
643 | to: '\u101d\u102d', |
||
644 | }, |
||
645 | { |
||
646 | from: '([^\u1040-\u1049])\u1040([^\u1040-\u1049\u0020]|[\u104a\u104b])', |
||
647 | to: '$1\u101d$2', |
||
648 | }, |
||
649 | { |
||
650 | from: '([^\u1040-\u1049])\u1040(?=[\\f\\n\\r])', |
||
651 | to: '$1\u101d', |
||
652 | }, |
||
653 | { |
||
654 | from: '([^\u1040-\u1049])\u1040$', |
||
655 | to: '$1\u101d', |
||
656 | }, |
||
657 | { |
||
658 | from: '\u1031([\u1000-\u1021])(\u103e)?(\u103b)?', |
||
659 | to: '$1$2$3\u1031', |
||
660 | }, |
||
661 | { |
||
662 | from: '([\u1000-\u1021])\u1031([\u103b\u103c\u103d\u103e]+)', |
||
663 | to: '$1$2\u1031', |
||
664 | }, |
||
665 | { |
||
666 | from: '\u1032\u103d', |
||
667 | to: '\u103d\u1032', |
||
668 | }, |
||
669 | { |
||
670 | from: '([\u102d\u102e])\u103b', |
||
671 | to: '\u103b$1', |
||
672 | }, |
||
673 | { |
||
674 | from: '\u103d\u103b', |
||
675 | to: '\u103b\u103d', |
||
676 | }, |
||
677 | { |
||
678 | from: '\u103a\u1037', |
||
679 | to: '\u1037\u103a', |
||
680 | }, |
||
681 | { |
||
682 | from: '\u102f(\u102d|\u102e|\u1036|\u1037)\u102f', |
||
683 | to: '\u102f$1', |
||
684 | }, |
||
685 | { |
||
686 | from: '(\u102f|\u1030)(\u102d|\u102e)', |
||
687 | to: '$2$1', |
||
688 | }, |
||
689 | { |
||
690 | from: '(\u103e)(\u103b|\u103c)', |
||
691 | to: '$2$1', |
||
692 | }, |
||
693 | { |
||
694 | from: '\u1025(?=[\u1037]?[\u103a\u102c])', |
||
695 | to: '\u1009', |
||
696 | }, |
||
697 | { |
||
698 | from: '\u1025\u102e', |
||
699 | to: '\u1026', |
||
700 | }, |
||
701 | { |
||
702 | from: '\u1005\u103b', |
||
703 | to: '\u1008', |
||
704 | }, |
||
705 | { |
||
706 | from: '\u1036(\u102f|\u1030)', |
||
707 | to: '$1\u1036', |
||
708 | }, |
||
709 | { |
||
710 | from: '\u1031\u1037\u103e', |
||
711 | to: '\u103e\u1031\u1037', |
||
712 | }, |
||
713 | { |
||
714 | from: '\u1031\u103e\u102c', |
||
715 | to: '\u103e\u1031\u102c', |
||
716 | }, |
||
717 | { |
||
718 | from: '\u105a', |
||
719 | to: '\u102b\u103a', |
||
720 | }, |
||
721 | { |
||
722 | from: '\u1031\u103b\u103e', |
||
723 | to: '\u103b\u103e\u1031', |
||
724 | }, |
||
725 | { |
||
726 | from: '(\u102d|\u102e)(\u103d|\u103e)', |
||
727 | to: '$2$1', |
||
728 | }, |
||
729 | { |
||
730 | from: '\u102c\u1039([\u1000-\u1021])', |
||
731 | to: '\u1039$1\u102c', |
||
732 | }, |
||
733 | { |
||
734 | from: '\u103c\u1004\u103a\u1039([\u1000-\u1021])', |
||
735 | to: '\u1004\u103a\u1039$1\u103c', |
||
736 | }, |
||
737 | { |
||
738 | from: '\u1039\u103c\u103a\u1039([\u1000-\u1021])', |
||
739 | to: '\u103a\u1039$1\u103c', |
||
740 | }, |
||
741 | { |
||
742 | from: '\u103c\u1039([\u1000-\u1021])', |
||
743 | to: '\u1039$1\u103c', |
||
744 | }, |
||
745 | { |
||
746 | from: '\u1036\u1039([\u1000-\u1021])', |
||
747 | to: '\u1039$1\u1036', |
||
748 | }, |
||
749 | { |
||
750 | from: '\u1092', |
||
751 | to: '\u100b\u1039\u100c', |
||
752 | }, |
||
753 | { |
||
754 | from: '\u104e', |
||
755 | to: '\u104e\u1004\u103a\u1038', |
||
756 | }, |
||
757 | { |
||
758 | from: '\u1040(\u102b|\u102c|\u1036)', |
||
759 | to: '\u101d$1', |
||
760 | }, |
||
761 | { |
||
762 | from: '\u1025\u1039', |
||
763 | to: '\u1009\u1039', |
||
764 | }, |
||
765 | { |
||
766 | from: '([\u1000-\u1021])\u103c\u1031\u103d', |
||
767 | to: '$1\u103c\u103d\u1031', |
||
768 | }, |
||
769 | { |
||
770 | from: '([\u1000-\u1021])\u103b\u1031\u103d(\u103e)?', |
||
771 | to: '$1\u103b\u103d$2\u1031', |
||
772 | }, |
||
773 | { |
||
774 | from: '([\u1000-\u1021])\u103d\u1031\u103b', |
||
775 | to: '$1\u103b\u103d\u1031', |
||
776 | }, |
||
777 | { |
||
778 | from: '([\u1000-\u1021])\u1031(\u1039[\u1000-\u1021])', |
||
779 | to: '$1$2\u1031', |
||
780 | }, |
||
781 | { |
||
782 | from: '\u1038\u103a', |
||
783 | to: '\u103a\u1038', |
||
784 | }, |
||
785 | { |
||
786 | from: '\u102d\u103a|\u103a\u102d', |
||
787 | to: '\u102d', |
||
788 | }, |
||
789 | { |
||
790 | from: '\u102d\u102f\u103a', |
||
791 | to: '\u102d\u102f', |
||
792 | }, |
||
793 | { |
||
794 | from: '\u0020\u1037', |
||
795 | to: '\u1037', |
||
796 | }, |
||
797 | { |
||
798 | from: '\u1037\u1036', |
||
799 | to: '\u1036\u1037', |
||
800 | }, |
||
801 | { |
||
802 | from: ' \u1037', |
||
803 | to: '\u1037', |
||
804 | }, |
||
805 | { |
||
806 | from: '[\u102d]+', |
||
807 | to: '\u102d', |
||
808 | }, |
||
809 | { |
||
810 | from: '[\u103a]+', |
||
811 | to: '\u103a', |
||
812 | }, |
||
813 | { |
||
814 | from: '[\u103d]+', |
||
815 | to: '\u103d', |
||
816 | }, |
||
817 | { |
||
818 | from: '[\u1037]+', |
||
819 | to: '\u1037', |
||
820 | }, |
||
821 | { |
||
822 | from: '[\u102e]+', |
||
823 | to: '\u102e', |
||
824 | }, |
||
825 | { |
||
826 | from: '\u102d\u102e|\u102e\u102d', |
||
827 | to: '\u102e', |
||
828 | }, |
||
829 | { |
||
830 | from: '\u102f\u102d', |
||
831 | to: '\u102d\u102f', |
||
832 | }, |
||
833 | { |
||
834 | from: '\u1037\u1037', |
||
835 | to: '\u1037', |
||
836 | }, |
||
837 | { |
||
838 | from: '\u1032\u1032', |
||
839 | to: '\u1032', |
||
840 | }, |
||
841 | { |
||
842 | from: '\u1044\u1004\u103a\u1038', |
||
843 | to: '\u104E\u1004\u103a\u1038', |
||
844 | }, |
||
845 | { |
||
846 | from: '([\u102d\u102e])\u1039([\u1000-\u1021])', |
||
847 | to: '\u1039$2$1', |
||
848 | }, |
||
849 | { |
||
850 | from: '\u1036\u103d', |
||
851 | to: '\u103d\u1036', |
||
852 | }, |
||
853 | ]; |
||
854 | return replaceWithRule(rule, output); |
||
855 | }; |
||
856 | const uniNormalize = (output) => { |
||
857 | if (!exports.isMyanmarText(output)) { |
||
858 | return output; |
||
859 | } |
||
860 | const rule = [ |
||
861 | { |
||
862 | from: '\u1025\u1013', |
||
863 | to: '\u1026', |
||
864 | }, |
||
865 | { |
||
866 | from: '\u101e\u103c', |
||
867 | to: '\u1029', |
||
868 | }, |
||
869 | { |
||
870 | from: '\u101e\u103c\u1031\u102c\u103A', |
||
871 | to: '\u102A', |
||
872 | }, |
||
873 | { |
||
874 | from: '\u102F\u102D', |
||
875 | to: '\u102D\u102F', |
||
876 | }, |
||
877 | ]; |
||
878 | return replaceWithRule(rule, output); |
||
879 | }; |
||
880 | exports.isUnicodeUser = () => { |
||
881 | return exports.getBrowserFont() === 'Unicode'; |
||
882 | }; |
||
883 | exports.textToWrite = (output) => { |
||
884 | return exports.isUnicodeUser() ? uniNormalize(output) : uniNormalize(exports.zg2uni(output)); |
||
885 | }; |
||
886 | exports.textToRead = (output) => { |
||
887 | return exports.isUnicodeUser() ? output : exports.uni2zg(output); |
||
888 | }; |
||
889 | exports.Virama = { |
||
890 | getBrowserFont: exports.getBrowserFont, |
||
891 | init, |
||
892 | isMyanmarText: exports.isMyanmarText, |
||
893 | isUnicodeUser: exports.isUnicodeUser, |
||
894 | textToRead: exports.textToRead, |
||
895 | textToWrite: exports.textToWrite, |
||
896 | uni2zg: exports.uni2zg, |
||
897 | zg2uni: exports.zg2uni, |
||
898 | }; |
||
899 |