-
Notifications
You must be signed in to change notification settings - Fork 1
/
totsv.js
51 lines (44 loc) · 1.02 KB
/
totsv.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
var sourceData = require('./table1.json');
var sourceData2 = require('./table2.json');
var output = [];
sourceData.forEach((character) => {
if (!character.infoArray) {
return;
}
character.infoArray.forEach((info) => {
if (info.reference) {
return;
}
output.push([character.ch, `U+${character.ch.codePointAt(0).toString(16).toUpperCase()}`, info.jyutping]);
});
});
sourceData2.forEach((character) => {
output.push([character.ch, `U+${character.part.codePointAt(0).toString(16).toUpperCase()}`, character.jyutping]);
});
output = output.sort((a, b) => {
if (a[1] < b[1]) {
return -1;
} else if (a[1] > b[1]) {
return 1;
} else {
return 0;
}
});
output = output.sort((a, b) => {
if (a[0] < b[0]) {
return -1;
} else if (a[0] > b[0]) {
return 1;
} else {
return 0;
}
});
var previousString = "";
for (let i = 0; i < output.length; i++) {
var tsv = output[i].join('\t')
if (tsv === previousString) {
continue;
}
previousString = tsv;
console.log(tsv);
}