mol_vary 0.0.97 → 0.0.99
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/node.deps.json +1 -1
- package/node.js +11 -5
- package/node.js.map +1 -1
- package/node.mjs +11 -5
- package/node.test.js +18 -7
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.js +11 -5
- package/web.js.map +1 -1
- package/web.mjs +11 -5
- package/web.test.js +7 -2
- package/web.test.js.map +1 -1
package/node.mjs
CHANGED
|
@@ -91,7 +91,7 @@ var $;
|
|
|
91
91
|
diacr_map[diacr_set[i]] = i | 0x80;
|
|
92
92
|
const wide_offset = 0x0E_00;
|
|
93
93
|
const wide_limit = 128 * 128 * 8 + wide_offset;
|
|
94
|
-
const
|
|
94
|
+
const tiny_limit = 128 * 98;
|
|
95
95
|
const full_mode = 0x95;
|
|
96
96
|
const wide_mode = 0x96;
|
|
97
97
|
const tiny_mode = 0x9E;
|
|
@@ -119,7 +119,7 @@ var $;
|
|
|
119
119
|
};
|
|
120
120
|
for (let i = 0; i < str.length; i++) {
|
|
121
121
|
let code = str.charCodeAt(i);
|
|
122
|
-
if (code >=
|
|
122
|
+
if (code >= 0xD8_00 && code < 0xDC_00)
|
|
123
123
|
code = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
|
|
124
124
|
if (code < 0x80) {
|
|
125
125
|
if (mode !== tiny_mode) {
|
|
@@ -129,7 +129,7 @@ var $;
|
|
|
129
129
|
}
|
|
130
130
|
buf[pos++] = code;
|
|
131
131
|
}
|
|
132
|
-
else if (code <
|
|
132
|
+
else if (code < tiny_limit) {
|
|
133
133
|
const page = (code >> 7) + tiny_mode;
|
|
134
134
|
code &= 0x7F;
|
|
135
135
|
if (page === 164) {
|
|
@@ -170,14 +170,20 @@ var $;
|
|
|
170
170
|
let text = '';
|
|
171
171
|
let pos = 0;
|
|
172
172
|
let page_offset = 0;
|
|
173
|
-
const
|
|
173
|
+
const read_code = () => {
|
|
174
174
|
let code = buffer[pos++];
|
|
175
175
|
if (code > 0x80)
|
|
176
176
|
code = ((mode + code) & 0x7F) | 0x80;
|
|
177
177
|
return code;
|
|
178
178
|
};
|
|
179
|
+
const read_remap = () => {
|
|
180
|
+
let code = read_code();
|
|
181
|
+
if (code >= 0x80)
|
|
182
|
+
code = ascii_set[code - 0x80];
|
|
183
|
+
return code;
|
|
184
|
+
};
|
|
179
185
|
while (pos < buffer.length) {
|
|
180
|
-
let code =
|
|
186
|
+
let code = read_code();
|
|
181
187
|
if (code < full_mode) {
|
|
182
188
|
if (mode === tiny_mode) {
|
|
183
189
|
if (code > 0x80) {
|
package/node.test.js
CHANGED
|
@@ -82,7 +82,7 @@ var $;
|
|
|
82
82
|
diacr_map[diacr_set[i]] = i | 0x80;
|
|
83
83
|
const wide_offset = 0x0E_00;
|
|
84
84
|
const wide_limit = 128 * 128 * 8 + wide_offset;
|
|
85
|
-
const
|
|
85
|
+
const tiny_limit = 128 * 98;
|
|
86
86
|
const full_mode = 0x95;
|
|
87
87
|
const wide_mode = 0x96;
|
|
88
88
|
const tiny_mode = 0x9E;
|
|
@@ -110,7 +110,7 @@ var $;
|
|
|
110
110
|
};
|
|
111
111
|
for (let i = 0; i < str.length; i++) {
|
|
112
112
|
let code = str.charCodeAt(i);
|
|
113
|
-
if (code >=
|
|
113
|
+
if (code >= 0xD8_00 && code < 0xDC_00)
|
|
114
114
|
code = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
|
|
115
115
|
if (code < 0x80) {
|
|
116
116
|
if (mode !== tiny_mode) {
|
|
@@ -120,7 +120,7 @@ var $;
|
|
|
120
120
|
}
|
|
121
121
|
buf[pos++] = code;
|
|
122
122
|
}
|
|
123
|
-
else if (code <
|
|
123
|
+
else if (code < tiny_limit) {
|
|
124
124
|
const page = (code >> 7) + tiny_mode;
|
|
125
125
|
code &= 0x7F;
|
|
126
126
|
if (page === 164) {
|
|
@@ -161,14 +161,20 @@ var $;
|
|
|
161
161
|
let text = '';
|
|
162
162
|
let pos = 0;
|
|
163
163
|
let page_offset = 0;
|
|
164
|
-
const
|
|
164
|
+
const read_code = () => {
|
|
165
165
|
let code = buffer[pos++];
|
|
166
166
|
if (code > 0x80)
|
|
167
167
|
code = ((mode + code) & 0x7F) | 0x80;
|
|
168
168
|
return code;
|
|
169
169
|
};
|
|
170
|
+
const read_remap = () => {
|
|
171
|
+
let code = read_code();
|
|
172
|
+
if (code >= 0x80)
|
|
173
|
+
code = ascii_set[code - 0x80];
|
|
174
|
+
return code;
|
|
175
|
+
};
|
|
170
176
|
while (pos < buffer.length) {
|
|
171
|
-
let code =
|
|
177
|
+
let code = read_code();
|
|
172
178
|
if (code < full_mode) {
|
|
173
179
|
if (mode === tiny_mode) {
|
|
174
180
|
if (code > 0x80) {
|
|
@@ -4526,8 +4532,8 @@ var $;
|
|
|
4526
4532
|
function check(text, bytes) {
|
|
4527
4533
|
const ideal = new Uint8Array(bytes);
|
|
4528
4534
|
const actual = $mol_charset_ucf_encode(text);
|
|
4529
|
-
$mol_assert_equal(actual, ideal);
|
|
4530
4535
|
$mol_assert_equal($mol_charset_ucf_decode(actual), text);
|
|
4536
|
+
$mol_assert_equal(actual, ideal);
|
|
4531
4537
|
}
|
|
4532
4538
|
$mol_test({
|
|
4533
4539
|
"Full ASCII compatible"($) {
|
|
@@ -4551,10 +4557,15 @@ var $;
|
|
|
4551
4557
|
"1B Kana"($) {
|
|
4552
4558
|
check('しい', [0xE0, 0x57, 0x44, 0xA0]);
|
|
4553
4559
|
},
|
|
4554
|
-
"2B Emoji
|
|
4560
|
+
"2B Emoji"($) {
|
|
4555
4561
|
check('🏴', [0xFF, 0x74, 0x4B, 0x81]);
|
|
4562
|
+
},
|
|
4563
|
+
"2B Emoji with 1B modifiers"($) {
|
|
4556
4564
|
check('🏴☠', [0xFF, 0x74, 0x4B, 0xC1, 0x0D, 0x8C, 0xA9, 0xB4]);
|
|
4557
4565
|
},
|
|
4566
|
+
"2B Emoji with 3B Tag"($) {
|
|
4567
|
+
check('🏴\u{E007F}', [0xFF, 0x74, 0x4B, 0xF8, 0x7F, 0x00, 0xF3, 0x89]);
|
|
4568
|
+
},
|
|
4558
4569
|
"Mixed scripts"($) {
|
|
4559
4570
|
check('allô 美しい мир, 🏴☠\n', [
|
|
4560
4571
|
0x61, 0x6C, 0x6C, 0x6F, 0xEA, 0x20,
|