forked from dance-dance-banana-frenzy/keen-unicoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
91 lines (82 loc) · 2.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const galacticStandardAlphabet = {
a: '',
b: '',
c: '',
d: '',
e: '',
f: '',
g: '',
h: '',
i: '',
j: '',
k: '',
l: '',
m: '',
n: '',
o: '',
p: '',
q: '',
r: '',
s: '',
t: '',
u: '',
v: '',
w: '',
x: '',
y: '',
z: '',
}
/*
const galacticStandardAlphabet = {
a: '\u158b', // CANADIAN SYLLABICS WEST-CREE RI
b: '\u154a', // CANADIAN SYLLABICS WEST-CREE LO
c: '\u0e32\u0e4d', // THAI CHARACTER SARA AA + THAI CHARACTER NIKHAHIT
d: '\u0a6e', // GURMUKHI DIGIT EIGHT
e: '\u14b7', // CANADIAN SYLLABICS WEST-CREE MWA
f: '\u{1d302}', // DIGRAM FOR HUMAN EARTH
g: '\u2ade', // SHORT LEFT TACK
h: '\u2ae7', // SHORT DOWN TACK WITH OVERBAR
i: '\u00a6', // BROKEN BAR
j: '\u205d', // TRICOLON
k: '\u5fc4', // CJK UNIFIED IDEOGRAPH-5FC4
l: '\u{1d106}', // MUSICAL SYMBOL LEFT REPEAT SIGN
m: '\u27d3', // LOWER RIGHT CORNER WITH DOT
n: '\u31fc', // KATAKANA LETTER SMALL RI,
o: '\u0a6d', // GURMUKHI DIGIT SEVEN
p: '\u0021\u00a1', // EXCLAMATION MARK + INVERTED EXCLAMATION MARK
q: '\u1451', // CANADIAN SYLLABICS TOO
r: '\u2237', // PROPORTION
s: '\u{200d1}', // CJK UNIFIED IDEOGRAPH-200D1
t: '\u3131', // HANGUL LETTER KIYEOK, MacKorean: A4A1
u: '\u2e1a', // HYPHEN WITH DIAERESIS
v: '\u2ae8', // SHORT UP TACK WITH UNDERBAR
w: '\u2234', // THEREFORE
x: '\ua718', // MODIFIER LETTER DOT SLASH
y: '\u{1d101}', // MUSICAL SYMBOL DOUBLE BARLINE
y: '\u{1d361}', // COUNTING ROD UNIT DIGIT TWO
z: '\u0548', // ARMENIAN CAPITAL LETTER VO
".": '._.'
}
*/
const fs = require('fs');
const toGalacticStandardAlphabet = char =>
galacticStandardAlphabet[char.toLowerCase()] || char;
const translate = text => text
.split("")
.map(toGalacticStandardAlphabet)
.join("");
const filePath = 'input.txt';
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading file: ${err}`);
return;
}
const gsa = translate(data);
console.log(gsa);
});
/*
const [,,...args] = process.argv;
const text = args.join(" ");
const gsa = translate(text);
console.log(gsa);
*/