@loaders.gl/polyfills 3.4.0-alpha.2 → 3.4.0-alpha.4
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/dist/dist.min.js +116 -40
- package/dist/es5/index.js +0 -5
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/encoding-indexes.js.map +1 -1
- package/dist/es5/lib/encoding.js +13 -384
- package/dist/es5/lib/encoding.js.map +1 -1
- package/dist/es5/node/buffer/btoa.node.js +0 -1
- package/dist/es5/node/buffer/btoa.node.js.map +1 -1
- package/dist/es5/node/buffer/to-array-buffer.node.js.map +1 -1
- package/dist/es5/node/fetch/fetch-file.node.js +41 -46
- package/dist/es5/node/fetch/fetch-file.node.js.map +1 -1
- package/dist/es5/node/fetch/fetch.node.js +84 -94
- package/dist/es5/node/fetch/fetch.node.js.map +1 -1
- package/dist/es5/node/fetch/headers.node.js +6 -9
- package/dist/es5/node/fetch/headers.node.js.map +1 -1
- package/dist/es5/node/fetch/response.node.js +56 -71
- package/dist/es5/node/fetch/response.node.js.map +1 -1
- package/dist/es5/node/fetch/utils/decode-data-uri.node.js +0 -6
- package/dist/es5/node/fetch/utils/decode-data-uri.node.js.map +1 -1
- package/dist/es5/node/fetch/utils/stream-utils.node.js +27 -35
- package/dist/es5/node/fetch/utils/stream-utils.node.js.map +1 -1
- package/dist/es5/node/file/blob-stream-controller.js +34 -40
- package/dist/es5/node/file/blob-stream-controller.js.map +1 -1
- package/dist/es5/node/file/blob-stream.js +10 -14
- package/dist/es5/node/file/blob-stream.js.map +1 -1
- package/dist/es5/node/file/blob.js +28 -42
- package/dist/es5/node/file/blob.js.map +1 -1
- package/dist/es5/node/file/file-reader.js +55 -64
- package/dist/es5/node/file/file-reader.js.map +1 -1
- package/dist/es5/node/file/file.js +0 -1
- package/dist/es5/node/file/file.js.map +1 -1
- package/dist/es5/node/file/install-file-polyfills.js +0 -1
- package/dist/es5/node/file/install-file-polyfills.js.map +1 -1
- package/dist/es5/node/file/readable-stream.js +0 -1
- package/dist/es5/node/file/readable-stream.js.map +1 -1
- package/dist/es5/node/images/encode-image.node.js +0 -2
- package/dist/es5/node/images/encode-image.node.js.map +1 -1
- package/dist/es5/node/images/parse-image.node.js +17 -22
- package/dist/es5/node/images/parse-image.node.js.map +1 -1
- package/dist/es5/promise/all-settled.js +0 -1
- package/dist/es5/promise/all-settled.js.map +1 -1
- package/dist/es5/utils/assert.js.map +1 -1
- package/dist/es5/utils/globals.js +1 -3
- package/dist/es5/utils/globals.js.map +1 -1
- package/dist/esm/bundle.js +0 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/encoding-indexes.js +0 -2
- package/dist/esm/lib/encoding-indexes.js.map +1 -1
- package/dist/esm/lib/encoding.js +11 -380
- package/dist/esm/lib/encoding.js.map +1 -1
- package/dist/esm/node/buffer/btoa.node.js +0 -2
- package/dist/esm/node/buffer/btoa.node.js.map +1 -1
- package/dist/esm/node/buffer/to-array-buffer.node.js.map +1 -1
- package/dist/esm/node/fetch/fetch-file.node.js +0 -4
- package/dist/esm/node/fetch/fetch-file.node.js.map +1 -1
- package/dist/esm/node/fetch/fetch.node.js +0 -13
- package/dist/esm/node/fetch/fetch.node.js.map +1 -1
- package/dist/esm/node/fetch/headers.node.js +0 -1
- package/dist/esm/node/fetch/headers.node.js.map +1 -1
- package/dist/esm/node/fetch/response.node.js +0 -5
- package/dist/esm/node/fetch/response.node.js.map +1 -1
- package/dist/esm/node/fetch/utils/decode-data-uri.node.js +0 -7
- package/dist/esm/node/fetch/utils/decode-data-uri.node.js.map +1 -1
- package/dist/esm/node/fetch/utils/stream-utils.node.js +0 -10
- package/dist/esm/node/fetch/utils/stream-utils.node.js.map +1 -1
- package/dist/esm/node/file/blob-stream-controller.js +0 -4
- package/dist/esm/node/file/blob-stream-controller.js.map +1 -1
- package/dist/esm/node/file/blob-stream.js +0 -2
- package/dist/esm/node/file/blob-stream.js.map +1 -1
- package/dist/esm/node/file/blob.js +0 -11
- package/dist/esm/node/file/blob.js.map +1 -1
- package/dist/esm/node/file/file-reader.js +0 -1
- package/dist/esm/node/file/file-reader.js.map +1 -1
- package/dist/esm/node/file/file.js +0 -2
- package/dist/esm/node/file/file.js.map +1 -1
- package/dist/esm/node/file/install-file-polyfills.js +0 -1
- package/dist/esm/node/file/install-file-polyfills.js.map +1 -1
- package/dist/esm/node/file/readable-stream.js +0 -2
- package/dist/esm/node/file/readable-stream.js.map +1 -1
- package/dist/esm/node/images/encode-image.node.js +0 -4
- package/dist/esm/node/images/encode-image.node.js.map +1 -1
- package/dist/esm/node/images/parse-image.node.js +0 -6
- package/dist/esm/node/images/parse-image.node.js.map +1 -1
- package/dist/esm/promise/all-settled.js +0 -1
- package/dist/esm/promise/all-settled.js.map +1 -1
- package/dist/esm/utils/assert.js.map +1 -1
- package/dist/esm/utils/globals.js +1 -4
- package/dist/esm/utils/globals.js.map +1 -1
- package/dist/lib/encoding.js +1 -1
- package/package.json +2 -2
package/dist/esm/lib/encoding.js
CHANGED
|
@@ -1,73 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
import indexes from './encoding-indexes';
|
|
4
2
|
global['encoding-indexes'] = indexes || {};
|
|
5
|
-
|
|
6
3
|
function inRange(a, min, max) {
|
|
7
4
|
return min <= a && a <= max;
|
|
8
5
|
}
|
|
9
|
-
|
|
10
6
|
function includes(array, item) {
|
|
11
7
|
return array.indexOf(item) !== -1;
|
|
12
8
|
}
|
|
13
9
|
var floor = Math.floor;
|
|
14
|
-
|
|
15
10
|
function ToDictionary(o) {
|
|
16
11
|
if (o === undefined) return {};
|
|
17
12
|
if (o === Object(o)) return o;
|
|
18
13
|
throw TypeError('Could not convert argument to dictionary');
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
function stringToCodePoints(string) {
|
|
22
|
-
|
|
23
16
|
var s = String(string);
|
|
24
|
-
|
|
25
17
|
var n = s.length;
|
|
26
|
-
|
|
27
18
|
var i = 0;
|
|
28
|
-
|
|
29
19
|
var u = [];
|
|
30
|
-
|
|
31
20
|
while (i < n) {
|
|
32
21
|
var c = s.charCodeAt(i);
|
|
33
|
-
|
|
34
22
|
if (c < 0xd800 || c > 0xdfff) {
|
|
35
23
|
u.push(c);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
else if (0xdc00 <= c && c <= 0xdfff) {
|
|
24
|
+
} else if (0xdc00 <= c && c <= 0xdfff) {
|
|
39
25
|
u.push(0xfffd);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
else if (0xd800 <= c && c <= 0xdbff) {
|
|
26
|
+
} else if (0xd800 <= c && c <= 0xdbff) {
|
|
43
27
|
if (i === n - 1) {
|
|
44
28
|
u.push(0xfffd);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
29
|
+
} else {
|
|
47
30
|
var d = s.charCodeAt(i + 1);
|
|
48
|
-
|
|
49
31
|
if (0xdc00 <= d && d <= 0xdfff) {
|
|
50
32
|
var a = c & 0x3ff;
|
|
51
|
-
|
|
52
33
|
var b = d & 0x3ff;
|
|
53
|
-
|
|
54
34
|
u.push(0x10000 + (a << 10) + b);
|
|
55
|
-
|
|
56
35
|
i += 1;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
else {
|
|
36
|
+
} else {
|
|
60
37
|
u.push(0xfffd);
|
|
61
38
|
}
|
|
62
39
|
}
|
|
63
40
|
}
|
|
64
|
-
|
|
65
41
|
i += 1;
|
|
66
42
|
}
|
|
67
|
-
|
|
68
43
|
return u;
|
|
69
44
|
}
|
|
70
|
-
|
|
71
45
|
function codePointsToString(code_points) {
|
|
72
46
|
var s = '';
|
|
73
47
|
for (var i = 0; i < code_points.length; ++i) {
|
|
@@ -81,15 +55,11 @@ function codePointsToString(code_points) {
|
|
|
81
55
|
}
|
|
82
56
|
return s;
|
|
83
57
|
}
|
|
84
|
-
|
|
85
58
|
function isASCIIByte(a) {
|
|
86
59
|
return 0x00 <= a && a <= 0x7f;
|
|
87
60
|
}
|
|
88
|
-
|
|
89
61
|
var isASCIICodePoint = isASCIIByte;
|
|
90
|
-
|
|
91
62
|
var end_of_stream = -1;
|
|
92
|
-
|
|
93
63
|
function Stream(tokens) {
|
|
94
64
|
this.tokens = [].slice.call(tokens);
|
|
95
65
|
this.tokens.reverse();
|
|
@@ -119,37 +89,29 @@ Stream.prototype = {
|
|
|
119
89
|
}
|
|
120
90
|
}
|
|
121
91
|
};
|
|
122
|
-
|
|
123
92
|
var finished = -1;
|
|
124
|
-
|
|
125
93
|
function decoderError(fatal, opt_code_point) {
|
|
126
94
|
if (fatal) throw TypeError('Decoder error');
|
|
127
95
|
return opt_code_point || 0xfffd;
|
|
128
96
|
}
|
|
129
|
-
|
|
130
97
|
function encoderError(code_point) {
|
|
131
98
|
throw TypeError('The code point ' + code_point + ' could not be encoded.');
|
|
132
99
|
}
|
|
133
|
-
|
|
134
100
|
function Decoder() {}
|
|
135
101
|
Decoder.prototype = {
|
|
136
102
|
handler: function (stream, bite) {}
|
|
137
103
|
};
|
|
138
|
-
|
|
139
104
|
function Encoder() {}
|
|
140
105
|
Encoder.prototype = {
|
|
141
106
|
handler: function (stream, code_point) {}
|
|
142
107
|
};
|
|
143
|
-
|
|
144
108
|
function getEncoding(label) {
|
|
145
109
|
label = String(label).trim().toLowerCase();
|
|
146
|
-
|
|
147
110
|
if (Object.prototype.hasOwnProperty.call(label_to_encoding, label)) {
|
|
148
111
|
return label_to_encoding[label];
|
|
149
112
|
}
|
|
150
113
|
return null;
|
|
151
114
|
}
|
|
152
|
-
|
|
153
115
|
var encodings = [{
|
|
154
116
|
encodings: [{
|
|
155
117
|
labels: ['unicode-1-1-utf-8', 'utf-8', 'utf8'],
|
|
@@ -292,7 +254,6 @@ var encodings = [{
|
|
|
292
254
|
}],
|
|
293
255
|
heading: 'Legacy miscellaneous encodings'
|
|
294
256
|
}];
|
|
295
|
-
|
|
296
257
|
var label_to_encoding = {};
|
|
297
258
|
encodings.forEach(function (category) {
|
|
298
259
|
category.encodings.forEach(function (encoding) {
|
|
@@ -301,32 +262,25 @@ encodings.forEach(function (category) {
|
|
|
301
262
|
});
|
|
302
263
|
});
|
|
303
264
|
});
|
|
304
|
-
|
|
305
265
|
var encoders = {};
|
|
306
266
|
var decoders = {};
|
|
307
|
-
|
|
308
267
|
function indexCodePointFor(pointer, index) {
|
|
309
268
|
if (!index) return null;
|
|
310
269
|
return index[pointer] || null;
|
|
311
270
|
}
|
|
312
|
-
|
|
313
271
|
function indexPointerFor(code_point, index) {
|
|
314
272
|
var pointer = index.indexOf(code_point);
|
|
315
273
|
return pointer === -1 ? null : pointer;
|
|
316
274
|
}
|
|
317
|
-
|
|
318
275
|
function index(name) {
|
|
319
276
|
if (!('encoding-indexes' in global)) {
|
|
320
277
|
throw Error('Indexes missing.' + ' Did you forget to include encoding-indexes.js first?');
|
|
321
278
|
}
|
|
322
279
|
return global['encoding-indexes'][name];
|
|
323
280
|
}
|
|
324
|
-
|
|
325
281
|
function indexGB18030RangesCodePointFor(pointer) {
|
|
326
282
|
if (pointer > 39419 && pointer < 189000 || pointer > 1237575) return null;
|
|
327
|
-
|
|
328
283
|
if (pointer === 7457) return 0xe7c7;
|
|
329
|
-
|
|
330
284
|
var offset = 0;
|
|
331
285
|
var code_point_offset = 0;
|
|
332
286
|
var idx = index('gb18030-ranges');
|
|
@@ -340,13 +294,10 @@ function indexGB18030RangesCodePointFor(pointer) {
|
|
|
340
294
|
break;
|
|
341
295
|
}
|
|
342
296
|
}
|
|
343
|
-
|
|
344
297
|
return code_point_offset + pointer - offset;
|
|
345
298
|
}
|
|
346
|
-
|
|
347
299
|
function indexGB18030RangesPointerFor(code_point) {
|
|
348
300
|
if (code_point === 0xe7c7) return 7457;
|
|
349
|
-
|
|
350
301
|
var offset = 0;
|
|
351
302
|
var pointer_offset = 0;
|
|
352
303
|
var idx = index('gb18030-ranges');
|
|
@@ -360,69 +311,52 @@ function indexGB18030RangesPointerFor(code_point) {
|
|
|
360
311
|
break;
|
|
361
312
|
}
|
|
362
313
|
}
|
|
363
|
-
|
|
364
314
|
return pointer_offset + code_point - offset;
|
|
365
315
|
}
|
|
366
|
-
|
|
367
316
|
function indexShiftJISPointerFor(code_point) {
|
|
368
317
|
shift_jis_index = shift_jis_index || index('jis0208').map(function (code_point, pointer) {
|
|
369
318
|
return inRange(pointer, 8272, 8835) ? null : code_point;
|
|
370
319
|
});
|
|
371
320
|
var index_ = shift_jis_index;
|
|
372
|
-
|
|
373
321
|
return index_.indexOf(code_point);
|
|
374
322
|
}
|
|
375
323
|
var shift_jis_index;
|
|
376
|
-
|
|
377
324
|
function indexBig5PointerFor(code_point) {
|
|
378
325
|
big5_index_no_hkscs = big5_index_no_hkscs || index('big5').map(function (code_point, pointer) {
|
|
379
326
|
return pointer < (0xa1 - 0x81) * 157 ? null : code_point;
|
|
380
327
|
});
|
|
381
328
|
var index_ = big5_index_no_hkscs;
|
|
382
|
-
|
|
383
329
|
if (code_point === 0x2550 || code_point === 0x255e || code_point === 0x2561 || code_point === 0x256a || code_point === 0x5341 || code_point === 0x5345) {
|
|
384
330
|
return index_.lastIndexOf(code_point);
|
|
385
331
|
}
|
|
386
|
-
|
|
387
332
|
return indexPointerFor(code_point, index_);
|
|
388
333
|
}
|
|
389
334
|
var big5_index_no_hkscs;
|
|
390
|
-
|
|
391
335
|
var DEFAULT_ENCODING = 'utf-8';
|
|
392
|
-
|
|
393
336
|
function TextDecoder(label, options) {
|
|
394
337
|
if (!(this instanceof TextDecoder)) throw TypeError("Called as a function. Did you forget 'new'?");
|
|
395
338
|
label = label !== undefined ? String(label) : DEFAULT_ENCODING;
|
|
396
339
|
options = ToDictionary(options);
|
|
397
|
-
|
|
398
340
|
this._encoding = null;
|
|
399
341
|
this._decoder = null;
|
|
400
342
|
this._ignoreBOM = false;
|
|
401
343
|
this._BOMseen = false;
|
|
402
344
|
this._error_mode = 'replacement';
|
|
403
345
|
this._do_not_flush = false;
|
|
404
|
-
|
|
405
346
|
var encoding = getEncoding(label);
|
|
406
|
-
|
|
407
347
|
if (encoding === null || encoding.name === 'replacement') throw RangeError('Unknown encoding: ' + label);
|
|
408
348
|
if (!decoders[encoding.name]) {
|
|
409
349
|
throw Error('Decoder not present.' + ' Did you forget to include encoding-indexes.js first?');
|
|
410
350
|
}
|
|
411
|
-
|
|
412
351
|
var dec = this;
|
|
413
|
-
|
|
414
352
|
dec._encoding = encoding;
|
|
415
|
-
|
|
416
353
|
if (Boolean(options['fatal'])) dec._error_mode = 'fatal';
|
|
417
|
-
|
|
418
354
|
if (Boolean(options['ignoreBOM'])) dec._ignoreBOM = true;
|
|
419
|
-
|
|
420
355
|
if (!Object.defineProperty) {
|
|
421
356
|
this.encoding = dec._encoding.name.toLowerCase();
|
|
422
357
|
this.fatal = dec._error_mode === 'fatal';
|
|
423
358
|
this.ignoreBOM = dec._ignoreBOM;
|
|
424
359
|
}
|
|
425
|
-
|
|
426
360
|
return dec;
|
|
427
361
|
}
|
|
428
362
|
if (Object.defineProperty) {
|
|
@@ -431,20 +365,17 @@ if (Object.defineProperty) {
|
|
|
431
365
|
return this._encoding.name.toLowerCase();
|
|
432
366
|
}
|
|
433
367
|
});
|
|
434
|
-
|
|
435
368
|
Object.defineProperty(TextDecoder.prototype, 'fatal', {
|
|
436
369
|
get: function () {
|
|
437
370
|
return this._error_mode === 'fatal';
|
|
438
371
|
}
|
|
439
372
|
});
|
|
440
|
-
|
|
441
373
|
Object.defineProperty(TextDecoder.prototype, 'ignoreBOM', {
|
|
442
374
|
get: function () {
|
|
443
375
|
return this._ignoreBOM;
|
|
444
376
|
}
|
|
445
377
|
});
|
|
446
378
|
}
|
|
447
|
-
|
|
448
379
|
TextDecoder.prototype.decode = function decode(input, options) {
|
|
449
380
|
var bytes;
|
|
450
381
|
if (typeof input === 'object' && input instanceof ArrayBuffer) {
|
|
@@ -455,34 +386,24 @@ TextDecoder.prototype.decode = function decode(input, options) {
|
|
|
455
386
|
bytes = new Uint8Array(0);
|
|
456
387
|
}
|
|
457
388
|
options = ToDictionary(options);
|
|
458
|
-
|
|
459
389
|
if (!this._do_not_flush) {
|
|
460
390
|
this._decoder = decoders[this._encoding.name]({
|
|
461
391
|
fatal: this._error_mode === 'fatal'
|
|
462
392
|
});
|
|
463
393
|
this._BOMseen = false;
|
|
464
394
|
}
|
|
465
|
-
|
|
466
395
|
this._do_not_flush = Boolean(options['stream']);
|
|
467
|
-
|
|
468
396
|
var input_stream = new Stream(bytes);
|
|
469
|
-
|
|
470
397
|
var output = [];
|
|
471
|
-
|
|
472
398
|
var result;
|
|
473
|
-
|
|
474
399
|
while (true) {
|
|
475
400
|
var token = input_stream.read();
|
|
476
|
-
|
|
477
401
|
if (token === end_of_stream) break;
|
|
478
|
-
|
|
479
402
|
result = this._decoder.handler(input_stream, token);
|
|
480
|
-
|
|
481
403
|
if (result === finished) break;
|
|
482
404
|
if (result !== null) {
|
|
483
405
|
if (Array.isArray(result)) output.push.apply(output, result);else output.push(result);
|
|
484
406
|
}
|
|
485
|
-
|
|
486
407
|
}
|
|
487
408
|
if (!this._do_not_flush) {
|
|
488
409
|
do {
|
|
@@ -493,35 +414,27 @@ TextDecoder.prototype.decode = function decode(input, options) {
|
|
|
493
414
|
} while (!input_stream.endOfStream());
|
|
494
415
|
this._decoder = null;
|
|
495
416
|
}
|
|
496
|
-
|
|
497
417
|
function serializeStream(stream) {
|
|
498
|
-
|
|
499
418
|
if (includes(['UTF-8', 'UTF-16LE', 'UTF-16BE'], this._encoding.name) && !this._ignoreBOM && !this._BOMseen) {
|
|
500
419
|
if (stream.length > 0 && stream[0] === 0xfeff) {
|
|
501
420
|
this._BOMseen = true;
|
|
502
421
|
stream.shift();
|
|
503
422
|
} else if (stream.length > 0) {
|
|
504
423
|
this._BOMseen = true;
|
|
505
|
-
} else {
|
|
506
|
-
}
|
|
424
|
+
} else {}
|
|
507
425
|
}
|
|
508
426
|
return codePointsToString(stream);
|
|
509
427
|
}
|
|
510
428
|
return serializeStream.call(this, output);
|
|
511
429
|
};
|
|
512
|
-
|
|
513
430
|
function TextEncoder(label, options) {
|
|
514
431
|
if (!(this instanceof TextEncoder)) throw TypeError("Called as a function. Did you forget 'new'?");
|
|
515
432
|
options = ToDictionary(options);
|
|
516
|
-
|
|
517
433
|
this._encoding = null;
|
|
518
434
|
this._encoder = null;
|
|
519
|
-
|
|
520
435
|
this._do_not_flush = false;
|
|
521
436
|
this._fatal = Boolean(options['fatal']) ? 'fatal' : 'replacement';
|
|
522
|
-
|
|
523
437
|
var enc = this;
|
|
524
|
-
|
|
525
438
|
if (Boolean(options['NONSTANDARD_allowLegacyEncoding'])) {
|
|
526
439
|
label = label !== undefined ? String(label) : DEFAULT_ENCODING;
|
|
527
440
|
var encoding = getEncoding(label);
|
|
@@ -536,9 +449,7 @@ function TextEncoder(label, options) {
|
|
|
536
449
|
console.warn('TextEncoder constructor called with encoding label, ' + 'which is ignored.');
|
|
537
450
|
}
|
|
538
451
|
}
|
|
539
|
-
|
|
540
452
|
if (!Object.defineProperty) this.encoding = enc._encoding.name.toLowerCase();
|
|
541
|
-
|
|
542
453
|
return enc;
|
|
543
454
|
}
|
|
544
455
|
if (Object.defineProperty) {
|
|
@@ -548,20 +459,15 @@ if (Object.defineProperty) {
|
|
|
548
459
|
}
|
|
549
460
|
});
|
|
550
461
|
}
|
|
551
|
-
|
|
552
462
|
TextEncoder.prototype.encode = function encode(opt_string, options) {
|
|
553
463
|
opt_string = opt_string === undefined ? '' : String(opt_string);
|
|
554
464
|
options = ToDictionary(options);
|
|
555
|
-
|
|
556
465
|
if (!this._do_not_flush) this._encoder = encoders[this._encoding.name]({
|
|
557
466
|
fatal: this._fatal === 'fatal'
|
|
558
467
|
});
|
|
559
468
|
this._do_not_flush = Boolean(options['stream']);
|
|
560
|
-
|
|
561
469
|
var input = new Stream(stringToCodePoints(opt_string));
|
|
562
|
-
|
|
563
470
|
var output = [];
|
|
564
|
-
|
|
565
471
|
var result;
|
|
566
472
|
while (true) {
|
|
567
473
|
var token = input.read();
|
|
@@ -580,151 +486,105 @@ TextEncoder.prototype.encode = function encode(opt_string, options) {
|
|
|
580
486
|
}
|
|
581
487
|
return new Uint8Array(output);
|
|
582
488
|
};
|
|
583
|
-
|
|
584
489
|
function UTF8Decoder(options) {
|
|
585
490
|
var fatal = options.fatal;
|
|
586
|
-
|
|
587
491
|
var utf8_code_point = 0,
|
|
588
492
|
utf8_bytes_seen = 0,
|
|
589
493
|
utf8_bytes_needed = 0,
|
|
590
494
|
utf8_lower_boundary = 0x80,
|
|
591
495
|
utf8_upper_boundary = 0xbf;
|
|
592
|
-
|
|
593
496
|
this.handler = function (stream, bite) {
|
|
594
497
|
if (bite === end_of_stream && utf8_bytes_needed !== 0) {
|
|
595
498
|
utf8_bytes_needed = 0;
|
|
596
499
|
return decoderError(fatal);
|
|
597
500
|
}
|
|
598
|
-
|
|
599
501
|
if (bite === end_of_stream) return finished;
|
|
600
|
-
|
|
601
502
|
if (utf8_bytes_needed === 0) {
|
|
602
503
|
if (inRange(bite, 0x00, 0x7f)) {
|
|
603
504
|
return bite;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
else if (inRange(bite, 0xc2, 0xdf)) {
|
|
505
|
+
} else if (inRange(bite, 0xc2, 0xdf)) {
|
|
607
506
|
utf8_bytes_needed = 1;
|
|
608
|
-
|
|
609
507
|
utf8_code_point = bite & 0x1f;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
else if (inRange(bite, 0xe0, 0xef)) {
|
|
508
|
+
} else if (inRange(bite, 0xe0, 0xef)) {
|
|
613
509
|
if (bite === 0xe0) utf8_lower_boundary = 0xa0;
|
|
614
510
|
if (bite === 0xed) utf8_upper_boundary = 0x9f;
|
|
615
511
|
utf8_bytes_needed = 2;
|
|
616
512
|
utf8_code_point = bite & 0xf;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
else if (inRange(bite, 0xf0, 0xf4)) {
|
|
513
|
+
} else if (inRange(bite, 0xf0, 0xf4)) {
|
|
620
514
|
if (bite === 0xf0) utf8_lower_boundary = 0x90;
|
|
621
515
|
if (bite === 0xf4) utf8_upper_boundary = 0x8f;
|
|
622
516
|
utf8_bytes_needed = 3;
|
|
623
517
|
utf8_code_point = bite & 0x7;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
else {
|
|
518
|
+
} else {
|
|
627
519
|
return decoderError(fatal);
|
|
628
520
|
}
|
|
629
|
-
|
|
630
521
|
return null;
|
|
631
522
|
}
|
|
632
|
-
|
|
633
523
|
if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {
|
|
634
524
|
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
|
|
635
525
|
utf8_lower_boundary = 0x80;
|
|
636
526
|
utf8_upper_boundary = 0xbf;
|
|
637
|
-
|
|
638
527
|
stream.prepend(bite);
|
|
639
|
-
|
|
640
528
|
return decoderError(fatal);
|
|
641
529
|
}
|
|
642
|
-
|
|
643
530
|
utf8_lower_boundary = 0x80;
|
|
644
531
|
utf8_upper_boundary = 0xbf;
|
|
645
|
-
|
|
646
532
|
utf8_code_point = utf8_code_point << 6 | bite & 0x3f;
|
|
647
|
-
|
|
648
533
|
utf8_bytes_seen += 1;
|
|
649
|
-
|
|
650
534
|
if (utf8_bytes_seen !== utf8_bytes_needed) return null;
|
|
651
|
-
|
|
652
535
|
var code_point = utf8_code_point;
|
|
653
|
-
|
|
654
536
|
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
|
|
655
|
-
|
|
656
537
|
return code_point;
|
|
657
538
|
};
|
|
658
539
|
}
|
|
659
|
-
|
|
660
540
|
function UTF8Encoder(options) {
|
|
661
541
|
var fatal = options.fatal;
|
|
662
542
|
this.handler = function (stream, code_point) {
|
|
663
543
|
if (code_point === end_of_stream) return finished;
|
|
664
|
-
|
|
665
544
|
if (isASCIICodePoint(code_point)) return code_point;
|
|
666
|
-
|
|
667
545
|
var count, offset;
|
|
668
546
|
if (inRange(code_point, 0x0080, 0x07ff)) {
|
|
669
547
|
count = 1;
|
|
670
548
|
offset = 0xc0;
|
|
671
|
-
}
|
|
672
|
-
else if (inRange(code_point, 0x0800, 0xffff)) {
|
|
549
|
+
} else if (inRange(code_point, 0x0800, 0xffff)) {
|
|
673
550
|
count = 2;
|
|
674
551
|
offset = 0xe0;
|
|
675
|
-
}
|
|
676
|
-
else if (inRange(code_point, 0x10000, 0x10ffff)) {
|
|
552
|
+
} else if (inRange(code_point, 0x10000, 0x10ffff)) {
|
|
677
553
|
count = 3;
|
|
678
554
|
offset = 0xf0;
|
|
679
555
|
}
|
|
680
|
-
|
|
681
556
|
var bytes = [(code_point >> 6 * count) + offset];
|
|
682
|
-
|
|
683
557
|
while (count > 0) {
|
|
684
558
|
var temp = code_point >> 6 * (count - 1);
|
|
685
|
-
|
|
686
559
|
bytes.push(0x80 | temp & 0x3f);
|
|
687
|
-
|
|
688
560
|
count -= 1;
|
|
689
561
|
}
|
|
690
|
-
|
|
691
562
|
return bytes;
|
|
692
563
|
};
|
|
693
564
|
}
|
|
694
|
-
|
|
695
565
|
encoders['UTF-8'] = function (options) {
|
|
696
566
|
return new UTF8Encoder(options);
|
|
697
567
|
};
|
|
698
568
|
decoders['UTF-8'] = function (options) {
|
|
699
569
|
return new UTF8Decoder(options);
|
|
700
570
|
};
|
|
701
|
-
|
|
702
571
|
function SingleByteDecoder(index, options) {
|
|
703
572
|
var fatal = options.fatal;
|
|
704
573
|
this.handler = function (stream, bite) {
|
|
705
574
|
if (bite === end_of_stream) return finished;
|
|
706
|
-
|
|
707
575
|
if (isASCIIByte(bite)) return bite;
|
|
708
|
-
|
|
709
576
|
var code_point = index[bite - 0x80];
|
|
710
|
-
|
|
711
577
|
if (code_point === null) return decoderError(fatal);
|
|
712
|
-
|
|
713
578
|
return code_point;
|
|
714
579
|
};
|
|
715
580
|
}
|
|
716
|
-
|
|
717
581
|
function SingleByteEncoder(index, options) {
|
|
718
582
|
var fatal = options.fatal;
|
|
719
583
|
this.handler = function (stream, code_point) {
|
|
720
584
|
if (code_point === end_of_stream) return finished;
|
|
721
|
-
|
|
722
585
|
if (isASCIICodePoint(code_point)) return code_point;
|
|
723
|
-
|
|
724
586
|
var pointer = indexPointerFor(code_point, index);
|
|
725
|
-
|
|
726
587
|
if (pointer === null) encoderError(code_point);
|
|
727
|
-
|
|
728
588
|
return pointer + 0x80;
|
|
729
589
|
};
|
|
730
590
|
}
|
|
@@ -744,15 +604,12 @@ function SingleByteEncoder(index, options) {
|
|
|
744
604
|
});
|
|
745
605
|
});
|
|
746
606
|
})();
|
|
747
|
-
|
|
748
607
|
decoders['GBK'] = function (options) {
|
|
749
608
|
return new GB18030Decoder(options);
|
|
750
609
|
};
|
|
751
|
-
|
|
752
610
|
encoders['GBK'] = function (options) {
|
|
753
611
|
return new GB18030Encoder(options, true);
|
|
754
612
|
};
|
|
755
|
-
|
|
756
613
|
function GB18030Decoder(options) {
|
|
757
614
|
var fatal = options.fatal;
|
|
758
615
|
var gb18030_first = 0x00,
|
|
@@ -774,140 +631,96 @@ function GB18030Decoder(options) {
|
|
|
774
631
|
if (inRange(bite, 0x30, 0x39)) {
|
|
775
632
|
code_point = indexGB18030RangesCodePointFor((((gb18030_first - 0x81) * 10 + gb18030_second - 0x30) * 126 + gb18030_third - 0x81) * 10 + bite - 0x30);
|
|
776
633
|
}
|
|
777
|
-
|
|
778
634
|
var buffer = [gb18030_second, gb18030_third, bite];
|
|
779
|
-
|
|
780
635
|
gb18030_first = 0x00;
|
|
781
636
|
gb18030_second = 0x00;
|
|
782
637
|
gb18030_third = 0x00;
|
|
783
|
-
|
|
784
638
|
if (code_point === null) {
|
|
785
639
|
stream.prepend(buffer);
|
|
786
640
|
return decoderError(fatal);
|
|
787
641
|
}
|
|
788
|
-
|
|
789
642
|
return code_point;
|
|
790
643
|
}
|
|
791
|
-
|
|
792
644
|
if (gb18030_second !== 0x00) {
|
|
793
645
|
if (inRange(bite, 0x81, 0xfe)) {
|
|
794
646
|
gb18030_third = bite;
|
|
795
647
|
return null;
|
|
796
648
|
}
|
|
797
|
-
|
|
798
649
|
stream.prepend([gb18030_second, bite]);
|
|
799
650
|
gb18030_first = 0x00;
|
|
800
651
|
gb18030_second = 0x00;
|
|
801
652
|
return decoderError(fatal);
|
|
802
653
|
}
|
|
803
|
-
|
|
804
654
|
if (gb18030_first !== 0x00) {
|
|
805
655
|
if (inRange(bite, 0x30, 0x39)) {
|
|
806
656
|
gb18030_second = bite;
|
|
807
657
|
return null;
|
|
808
658
|
}
|
|
809
|
-
|
|
810
659
|
var lead = gb18030_first;
|
|
811
660
|
var pointer = null;
|
|
812
661
|
gb18030_first = 0x00;
|
|
813
|
-
|
|
814
662
|
var offset = bite < 0x7f ? 0x40 : 0x41;
|
|
815
|
-
|
|
816
663
|
if (inRange(bite, 0x40, 0x7e) || inRange(bite, 0x80, 0xfe)) pointer = (lead - 0x81) * 190 + (bite - offset);
|
|
817
|
-
|
|
818
664
|
code_point = pointer === null ? null : indexCodePointFor(pointer, index('gb18030'));
|
|
819
|
-
|
|
820
665
|
if (code_point === null && isASCIIByte(bite)) stream.prepend(bite);
|
|
821
|
-
|
|
822
666
|
if (code_point === null) return decoderError(fatal);
|
|
823
|
-
|
|
824
667
|
return code_point;
|
|
825
668
|
}
|
|
826
|
-
|
|
827
669
|
if (isASCIIByte(bite)) return bite;
|
|
828
|
-
|
|
829
670
|
if (bite === 0x80) return 0x20ac;
|
|
830
|
-
|
|
831
671
|
if (inRange(bite, 0x81, 0xfe)) {
|
|
832
672
|
gb18030_first = bite;
|
|
833
673
|
return null;
|
|
834
674
|
}
|
|
835
|
-
|
|
836
675
|
return decoderError(fatal);
|
|
837
676
|
};
|
|
838
677
|
}
|
|
839
|
-
|
|
840
678
|
function GB18030Encoder(options, gbk_flag) {
|
|
841
679
|
var fatal = options.fatal;
|
|
842
680
|
this.handler = function (stream, code_point) {
|
|
843
681
|
if (code_point === end_of_stream) return finished;
|
|
844
|
-
|
|
845
682
|
if (isASCIICodePoint(code_point)) return code_point;
|
|
846
|
-
|
|
847
683
|
if (code_point === 0xe5e5) return encoderError(code_point);
|
|
848
|
-
|
|
849
684
|
if (gbk_flag && code_point === 0x20ac) return 0x80;
|
|
850
|
-
|
|
851
685
|
var pointer = indexPointerFor(code_point, index('gb18030'));
|
|
852
|
-
|
|
853
686
|
if (pointer !== null) {
|
|
854
687
|
var lead = floor(pointer / 190) + 0x81;
|
|
855
|
-
|
|
856
688
|
var trail = pointer % 190;
|
|
857
|
-
|
|
858
689
|
var offset = trail < 0x3f ? 0x40 : 0x41;
|
|
859
|
-
|
|
860
690
|
return [lead, trail + offset];
|
|
861
691
|
}
|
|
862
|
-
|
|
863
692
|
if (gbk_flag) return encoderError(code_point);
|
|
864
|
-
|
|
865
693
|
pointer = indexGB18030RangesPointerFor(code_point);
|
|
866
|
-
|
|
867
694
|
var byte1 = floor(pointer / 10 / 126 / 10);
|
|
868
|
-
|
|
869
695
|
pointer = pointer - byte1 * 10 * 126 * 10;
|
|
870
|
-
|
|
871
696
|
var byte2 = floor(pointer / 10 / 126);
|
|
872
|
-
|
|
873
697
|
pointer = pointer - byte2 * 10 * 126;
|
|
874
|
-
|
|
875
698
|
var byte3 = floor(pointer / 10);
|
|
876
|
-
|
|
877
699
|
var byte4 = pointer - byte3 * 10;
|
|
878
|
-
|
|
879
700
|
return [byte1 + 0x81, byte2 + 0x30, byte3 + 0x81, byte4 + 0x30];
|
|
880
701
|
};
|
|
881
702
|
}
|
|
882
|
-
|
|
883
703
|
encoders['gb18030'] = function (options) {
|
|
884
704
|
return new GB18030Encoder(options);
|
|
885
705
|
};
|
|
886
706
|
decoders['gb18030'] = function (options) {
|
|
887
707
|
return new GB18030Decoder(options);
|
|
888
708
|
};
|
|
889
|
-
|
|
890
709
|
function Big5Decoder(options) {
|
|
891
710
|
var fatal = options.fatal;
|
|
892
711
|
var Big5_lead = 0x00;
|
|
893
|
-
|
|
894
712
|
this.handler = function (stream, bite) {
|
|
895
713
|
if (bite === end_of_stream && Big5_lead !== 0x00) {
|
|
896
714
|
Big5_lead = 0x00;
|
|
897
715
|
return decoderError(fatal);
|
|
898
716
|
}
|
|
899
|
-
|
|
900
717
|
if (bite === end_of_stream && Big5_lead === 0x00) return finished;
|
|
901
|
-
|
|
902
718
|
if (Big5_lead !== 0x00) {
|
|
903
719
|
var lead = Big5_lead;
|
|
904
720
|
var pointer = null;
|
|
905
721
|
Big5_lead = 0x00;
|
|
906
|
-
|
|
907
722
|
var offset = bite < 0x7f ? 0x40 : 0x62;
|
|
908
|
-
|
|
909
723
|
if (inRange(bite, 0x40, 0x7e) || inRange(bite, 0xa1, 0xfe)) pointer = (lead - 0x81) * 157 + (bite - offset);
|
|
910
|
-
|
|
911
724
|
switch (pointer) {
|
|
912
725
|
case 1133:
|
|
913
726
|
return [0x00ca, 0x0304];
|
|
@@ -918,146 +731,100 @@ function Big5Decoder(options) {
|
|
|
918
731
|
case 1166:
|
|
919
732
|
return [0x00ea, 0x030c];
|
|
920
733
|
}
|
|
921
|
-
|
|
922
734
|
var code_point = pointer === null ? null : indexCodePointFor(pointer, index('big5'));
|
|
923
|
-
|
|
924
735
|
if (code_point === null && isASCIIByte(bite)) stream.prepend(bite);
|
|
925
|
-
|
|
926
736
|
if (code_point === null) return decoderError(fatal);
|
|
927
|
-
|
|
928
737
|
return code_point;
|
|
929
738
|
}
|
|
930
|
-
|
|
931
739
|
if (isASCIIByte(bite)) return bite;
|
|
932
|
-
|
|
933
740
|
if (inRange(bite, 0x81, 0xfe)) {
|
|
934
741
|
Big5_lead = bite;
|
|
935
742
|
return null;
|
|
936
743
|
}
|
|
937
|
-
|
|
938
744
|
return decoderError(fatal);
|
|
939
745
|
};
|
|
940
746
|
}
|
|
941
|
-
|
|
942
747
|
function Big5Encoder(options) {
|
|
943
748
|
var fatal = options.fatal;
|
|
944
749
|
this.handler = function (stream, code_point) {
|
|
945
750
|
if (code_point === end_of_stream) return finished;
|
|
946
|
-
|
|
947
751
|
if (isASCIICodePoint(code_point)) return code_point;
|
|
948
|
-
|
|
949
752
|
var pointer = indexBig5PointerFor(code_point);
|
|
950
|
-
|
|
951
753
|
if (pointer === null) return encoderError(code_point);
|
|
952
|
-
|
|
953
754
|
var lead = floor(pointer / 157) + 0x81;
|
|
954
|
-
|
|
955
755
|
if (lead < 0xa1) return encoderError(code_point);
|
|
956
|
-
|
|
957
756
|
var trail = pointer % 157;
|
|
958
|
-
|
|
959
757
|
var offset = trail < 0x3f ? 0x40 : 0x62;
|
|
960
|
-
|
|
961
758
|
return [lead, trail + offset];
|
|
962
759
|
};
|
|
963
760
|
}
|
|
964
|
-
|
|
965
761
|
encoders['Big5'] = function (options) {
|
|
966
762
|
return new Big5Encoder(options);
|
|
967
763
|
};
|
|
968
764
|
decoders['Big5'] = function (options) {
|
|
969
765
|
return new Big5Decoder(options);
|
|
970
766
|
};
|
|
971
|
-
|
|
972
767
|
function EUCJPDecoder(options) {
|
|
973
768
|
var fatal = options.fatal;
|
|
974
|
-
|
|
975
769
|
var eucjp_jis0212_flag = false,
|
|
976
770
|
eucjp_lead = 0x00;
|
|
977
|
-
|
|
978
771
|
this.handler = function (stream, bite) {
|
|
979
772
|
if (bite === end_of_stream && eucjp_lead !== 0x00) {
|
|
980
773
|
eucjp_lead = 0x00;
|
|
981
774
|
return decoderError(fatal);
|
|
982
775
|
}
|
|
983
|
-
|
|
984
776
|
if (bite === end_of_stream && eucjp_lead === 0x00) return finished;
|
|
985
|
-
|
|
986
777
|
if (eucjp_lead === 0x8e && inRange(bite, 0xa1, 0xdf)) {
|
|
987
778
|
eucjp_lead = 0x00;
|
|
988
779
|
return 0xff61 - 0xa1 + bite;
|
|
989
780
|
}
|
|
990
|
-
|
|
991
781
|
if (eucjp_lead === 0x8f && inRange(bite, 0xa1, 0xfe)) {
|
|
992
782
|
eucjp_jis0212_flag = true;
|
|
993
783
|
eucjp_lead = bite;
|
|
994
784
|
return null;
|
|
995
785
|
}
|
|
996
|
-
|
|
997
786
|
if (eucjp_lead !== 0x00) {
|
|
998
787
|
var lead = eucjp_lead;
|
|
999
788
|
eucjp_lead = 0x00;
|
|
1000
|
-
|
|
1001
789
|
var code_point = null;
|
|
1002
|
-
|
|
1003
790
|
if (inRange(lead, 0xa1, 0xfe) && inRange(bite, 0xa1, 0xfe)) {
|
|
1004
791
|
code_point = indexCodePointFor((lead - 0xa1) * 94 + (bite - 0xa1), index(!eucjp_jis0212_flag ? 'jis0208' : 'jis0212'));
|
|
1005
792
|
}
|
|
1006
|
-
|
|
1007
793
|
eucjp_jis0212_flag = false;
|
|
1008
|
-
|
|
1009
794
|
if (!inRange(bite, 0xa1, 0xfe)) stream.prepend(bite);
|
|
1010
|
-
|
|
1011
795
|
if (code_point === null) return decoderError(fatal);
|
|
1012
|
-
|
|
1013
796
|
return code_point;
|
|
1014
797
|
}
|
|
1015
|
-
|
|
1016
798
|
if (isASCIIByte(bite)) return bite;
|
|
1017
|
-
|
|
1018
799
|
if (bite === 0x8e || bite === 0x8f || inRange(bite, 0xa1, 0xfe)) {
|
|
1019
800
|
eucjp_lead = bite;
|
|
1020
801
|
return null;
|
|
1021
802
|
}
|
|
1022
|
-
|
|
1023
803
|
return decoderError(fatal);
|
|
1024
804
|
};
|
|
1025
805
|
}
|
|
1026
|
-
|
|
1027
806
|
function EUCJPEncoder(options) {
|
|
1028
807
|
var fatal = options.fatal;
|
|
1029
808
|
this.handler = function (stream, code_point) {
|
|
1030
809
|
if (code_point === end_of_stream) return finished;
|
|
1031
|
-
|
|
1032
810
|
if (isASCIICodePoint(code_point)) return code_point;
|
|
1033
|
-
|
|
1034
811
|
if (code_point === 0x00a5) return 0x5c;
|
|
1035
|
-
|
|
1036
812
|
if (code_point === 0x203e) return 0x7e;
|
|
1037
|
-
|
|
1038
813
|
if (inRange(code_point, 0xff61, 0xff9f)) return [0x8e, code_point - 0xff61 + 0xa1];
|
|
1039
|
-
|
|
1040
814
|
if (code_point === 0x2212) code_point = 0xff0d;
|
|
1041
|
-
|
|
1042
815
|
var pointer = indexPointerFor(code_point, index('jis0208'));
|
|
1043
|
-
|
|
1044
816
|
if (pointer === null) return encoderError(code_point);
|
|
1045
|
-
|
|
1046
817
|
var lead = floor(pointer / 94) + 0xa1;
|
|
1047
|
-
|
|
1048
818
|
var trail = pointer % 94 + 0xa1;
|
|
1049
|
-
|
|
1050
819
|
return [lead, trail];
|
|
1051
820
|
};
|
|
1052
821
|
}
|
|
1053
|
-
|
|
1054
822
|
encoders['EUC-JP'] = function (options) {
|
|
1055
823
|
return new EUCJPEncoder(options);
|
|
1056
824
|
};
|
|
1057
825
|
decoders['EUC-JP'] = function (options) {
|
|
1058
826
|
return new EUCJPDecoder(options);
|
|
1059
827
|
};
|
|
1060
|
-
|
|
1061
828
|
function ISO2022JPDecoder(options) {
|
|
1062
829
|
var fatal = options.fatal;
|
|
1063
830
|
var states = {
|
|
@@ -1077,163 +844,121 @@ function ISO2022JPDecoder(options) {
|
|
|
1077
844
|
switch (iso2022jp_decoder_state) {
|
|
1078
845
|
default:
|
|
1079
846
|
case states.ASCII:
|
|
1080
|
-
|
|
1081
847
|
if (bite === 0x1b) {
|
|
1082
848
|
iso2022jp_decoder_state = states.EscapeStart;
|
|
1083
849
|
return null;
|
|
1084
850
|
}
|
|
1085
|
-
|
|
1086
851
|
if (inRange(bite, 0x00, 0x7f) && bite !== 0x0e && bite !== 0x0f && bite !== 0x1b) {
|
|
1087
852
|
iso2022jp_output_flag = false;
|
|
1088
853
|
return bite;
|
|
1089
854
|
}
|
|
1090
|
-
|
|
1091
855
|
if (bite === end_of_stream) {
|
|
1092
856
|
return finished;
|
|
1093
857
|
}
|
|
1094
|
-
|
|
1095
858
|
iso2022jp_output_flag = false;
|
|
1096
859
|
return decoderError(fatal);
|
|
1097
860
|
case states.Roman:
|
|
1098
|
-
|
|
1099
861
|
if (bite === 0x1b) {
|
|
1100
862
|
iso2022jp_decoder_state = states.EscapeStart;
|
|
1101
863
|
return null;
|
|
1102
864
|
}
|
|
1103
|
-
|
|
1104
865
|
if (bite === 0x5c) {
|
|
1105
866
|
iso2022jp_output_flag = false;
|
|
1106
867
|
return 0x00a5;
|
|
1107
868
|
}
|
|
1108
|
-
|
|
1109
869
|
if (bite === 0x7e) {
|
|
1110
870
|
iso2022jp_output_flag = false;
|
|
1111
871
|
return 0x203e;
|
|
1112
872
|
}
|
|
1113
|
-
|
|
1114
873
|
if (inRange(bite, 0x00, 0x7f) && bite !== 0x0e && bite !== 0x0f && bite !== 0x1b && bite !== 0x5c && bite !== 0x7e) {
|
|
1115
874
|
iso2022jp_output_flag = false;
|
|
1116
875
|
return bite;
|
|
1117
876
|
}
|
|
1118
|
-
|
|
1119
877
|
if (bite === end_of_stream) {
|
|
1120
878
|
return finished;
|
|
1121
879
|
}
|
|
1122
|
-
|
|
1123
880
|
iso2022jp_output_flag = false;
|
|
1124
881
|
return decoderError(fatal);
|
|
1125
882
|
case states.Katakana:
|
|
1126
|
-
|
|
1127
883
|
if (bite === 0x1b) {
|
|
1128
884
|
iso2022jp_decoder_state = states.EscapeStart;
|
|
1129
885
|
return null;
|
|
1130
886
|
}
|
|
1131
|
-
|
|
1132
887
|
if (inRange(bite, 0x21, 0x5f)) {
|
|
1133
888
|
iso2022jp_output_flag = false;
|
|
1134
889
|
return 0xff61 - 0x21 + bite;
|
|
1135
890
|
}
|
|
1136
|
-
|
|
1137
891
|
if (bite === end_of_stream) {
|
|
1138
892
|
return finished;
|
|
1139
893
|
}
|
|
1140
|
-
|
|
1141
894
|
iso2022jp_output_flag = false;
|
|
1142
895
|
return decoderError(fatal);
|
|
1143
896
|
case states.LeadByte:
|
|
1144
|
-
|
|
1145
897
|
if (bite === 0x1b) {
|
|
1146
898
|
iso2022jp_decoder_state = states.EscapeStart;
|
|
1147
899
|
return null;
|
|
1148
900
|
}
|
|
1149
|
-
|
|
1150
901
|
if (inRange(bite, 0x21, 0x7e)) {
|
|
1151
902
|
iso2022jp_output_flag = false;
|
|
1152
903
|
iso2022jp_lead = bite;
|
|
1153
904
|
iso2022jp_decoder_state = states.TrailByte;
|
|
1154
905
|
return null;
|
|
1155
906
|
}
|
|
1156
|
-
|
|
1157
907
|
if (bite === end_of_stream) {
|
|
1158
908
|
return finished;
|
|
1159
909
|
}
|
|
1160
|
-
|
|
1161
910
|
iso2022jp_output_flag = false;
|
|
1162
911
|
return decoderError(fatal);
|
|
1163
912
|
case states.TrailByte:
|
|
1164
|
-
|
|
1165
913
|
if (bite === 0x1b) {
|
|
1166
914
|
iso2022jp_decoder_state = states.EscapeStart;
|
|
1167
915
|
return decoderError(fatal);
|
|
1168
916
|
}
|
|
1169
|
-
|
|
1170
917
|
if (inRange(bite, 0x21, 0x7e)) {
|
|
1171
918
|
iso2022jp_decoder_state = states.LeadByte;
|
|
1172
|
-
|
|
1173
919
|
var pointer = (iso2022jp_lead - 0x21) * 94 + bite - 0x21;
|
|
1174
|
-
|
|
1175
920
|
var code_point = indexCodePointFor(pointer, index('jis0208'));
|
|
1176
|
-
|
|
1177
921
|
if (code_point === null) return decoderError(fatal);
|
|
1178
|
-
|
|
1179
922
|
return code_point;
|
|
1180
923
|
}
|
|
1181
|
-
|
|
1182
924
|
if (bite === end_of_stream) {
|
|
1183
925
|
iso2022jp_decoder_state = states.LeadByte;
|
|
1184
926
|
stream.prepend(bite);
|
|
1185
927
|
return decoderError(fatal);
|
|
1186
928
|
}
|
|
1187
|
-
|
|
1188
929
|
iso2022jp_decoder_state = states.LeadByte;
|
|
1189
930
|
return decoderError(fatal);
|
|
1190
931
|
case states.EscapeStart:
|
|
1191
|
-
|
|
1192
932
|
if (bite === 0x24 || bite === 0x28) {
|
|
1193
933
|
iso2022jp_lead = bite;
|
|
1194
934
|
iso2022jp_decoder_state = states.Escape;
|
|
1195
935
|
return null;
|
|
1196
936
|
}
|
|
1197
|
-
|
|
1198
937
|
stream.prepend(bite);
|
|
1199
|
-
|
|
1200
938
|
iso2022jp_output_flag = false;
|
|
1201
939
|
iso2022jp_decoder_state = iso2022jp_decoder_output_state;
|
|
1202
940
|
return decoderError(fatal);
|
|
1203
941
|
case states.Escape:
|
|
1204
|
-
|
|
1205
942
|
var lead = iso2022jp_lead;
|
|
1206
943
|
iso2022jp_lead = 0x00;
|
|
1207
|
-
|
|
1208
944
|
var state = null;
|
|
1209
|
-
|
|
1210
945
|
if (lead === 0x28 && bite === 0x42) state = states.ASCII;
|
|
1211
|
-
|
|
1212
946
|
if (lead === 0x28 && bite === 0x4a) state = states.Roman;
|
|
1213
|
-
|
|
1214
947
|
if (lead === 0x28 && bite === 0x49) state = states.Katakana;
|
|
1215
|
-
|
|
1216
948
|
if (lead === 0x24 && (bite === 0x40 || bite === 0x42)) state = states.LeadByte;
|
|
1217
|
-
|
|
1218
949
|
if (state !== null) {
|
|
1219
950
|
iso2022jp_decoder_state = iso2022jp_decoder_state = state;
|
|
1220
|
-
|
|
1221
951
|
var output_flag = iso2022jp_output_flag;
|
|
1222
|
-
|
|
1223
952
|
iso2022jp_output_flag = true;
|
|
1224
|
-
|
|
1225
953
|
return !output_flag ? null : decoderError(fatal);
|
|
1226
954
|
}
|
|
1227
|
-
|
|
1228
955
|
stream.prepend([lead, bite]);
|
|
1229
|
-
|
|
1230
956
|
iso2022jp_output_flag = false;
|
|
1231
957
|
iso2022jp_decoder_state = iso2022jp_decoder_output_state;
|
|
1232
958
|
return decoderError(fatal);
|
|
1233
959
|
}
|
|
1234
960
|
};
|
|
1235
961
|
}
|
|
1236
|
-
|
|
1237
962
|
function ISO2022JPEncoder(options) {
|
|
1238
963
|
var fatal = options.fatal;
|
|
1239
964
|
var states = {
|
|
@@ -1248,62 +973,45 @@ function ISO2022JPEncoder(options) {
|
|
|
1248
973
|
iso2022jp_state = states.ASCII;
|
|
1249
974
|
return [0x1b, 0x28, 0x42];
|
|
1250
975
|
}
|
|
1251
|
-
|
|
1252
976
|
if (code_point === end_of_stream && iso2022jp_state === states.ASCII) return finished;
|
|
1253
|
-
|
|
1254
977
|
if ((iso2022jp_state === states.ASCII || iso2022jp_state === states.Roman) && (code_point === 0x000e || code_point === 0x000f || code_point === 0x001b)) {
|
|
1255
978
|
return encoderError(0xfffd);
|
|
1256
979
|
}
|
|
1257
|
-
|
|
1258
980
|
if (iso2022jp_state === states.ASCII && isASCIICodePoint(code_point)) return code_point;
|
|
1259
|
-
|
|
1260
981
|
if (iso2022jp_state === states.Roman && (isASCIICodePoint(code_point) && code_point !== 0x005c && code_point !== 0x007e || code_point == 0x00a5 || code_point == 0x203e)) {
|
|
1261
982
|
if (isASCIICodePoint(code_point)) return code_point;
|
|
1262
|
-
|
|
1263
983
|
if (code_point === 0x00a5) return 0x5c;
|
|
1264
|
-
|
|
1265
984
|
if (code_point === 0x203e) return 0x7e;
|
|
1266
985
|
}
|
|
1267
|
-
|
|
1268
986
|
if (isASCIICodePoint(code_point) && iso2022jp_state !== states.ASCII) {
|
|
1269
987
|
stream.prepend(code_point);
|
|
1270
988
|
iso2022jp_state = states.ASCII;
|
|
1271
989
|
return [0x1b, 0x28, 0x42];
|
|
1272
990
|
}
|
|
1273
|
-
|
|
1274
991
|
if ((code_point === 0x00a5 || code_point === 0x203e) && iso2022jp_state !== states.Roman) {
|
|
1275
992
|
stream.prepend(code_point);
|
|
1276
993
|
iso2022jp_state = states.Roman;
|
|
1277
994
|
return [0x1b, 0x28, 0x4a];
|
|
1278
995
|
}
|
|
1279
|
-
|
|
1280
996
|
if (code_point === 0x2212) code_point = 0xff0d;
|
|
1281
|
-
|
|
1282
997
|
var pointer = indexPointerFor(code_point, index('jis0208'));
|
|
1283
|
-
|
|
1284
998
|
if (pointer === null) return encoderError(code_point);
|
|
1285
|
-
|
|
1286
999
|
if (iso2022jp_state !== states.jis0208) {
|
|
1287
1000
|
stream.prepend(code_point);
|
|
1288
1001
|
iso2022jp_state = states.jis0208;
|
|
1289
1002
|
return [0x1b, 0x24, 0x42];
|
|
1290
1003
|
}
|
|
1291
|
-
|
|
1292
1004
|
var lead = floor(pointer / 94) + 0x21;
|
|
1293
|
-
|
|
1294
1005
|
var trail = pointer % 94 + 0x21;
|
|
1295
|
-
|
|
1296
1006
|
return [lead, trail];
|
|
1297
1007
|
};
|
|
1298
1008
|
}
|
|
1299
|
-
|
|
1300
1009
|
encoders['ISO-2022-JP'] = function (options) {
|
|
1301
1010
|
return new ISO2022JPEncoder(options);
|
|
1302
1011
|
};
|
|
1303
1012
|
decoders['ISO-2022-JP'] = function (options) {
|
|
1304
1013
|
return new ISO2022JPDecoder(options);
|
|
1305
1014
|
};
|
|
1306
|
-
|
|
1307
1015
|
function ShiftJISDecoder(options) {
|
|
1308
1016
|
var fatal = options.fatal;
|
|
1309
1017
|
var Shift_JIS_lead = 0x00;
|
|
@@ -1312,156 +1020,104 @@ function ShiftJISDecoder(options) {
|
|
|
1312
1020
|
Shift_JIS_lead = 0x00;
|
|
1313
1021
|
return decoderError(fatal);
|
|
1314
1022
|
}
|
|
1315
|
-
|
|
1316
1023
|
if (bite === end_of_stream && Shift_JIS_lead === 0x00) return finished;
|
|
1317
|
-
|
|
1318
1024
|
if (Shift_JIS_lead !== 0x00) {
|
|
1319
1025
|
var lead = Shift_JIS_lead;
|
|
1320
1026
|
var pointer = null;
|
|
1321
1027
|
Shift_JIS_lead = 0x00;
|
|
1322
|
-
|
|
1323
1028
|
var offset = bite < 0x7f ? 0x40 : 0x41;
|
|
1324
|
-
|
|
1325
1029
|
var lead_offset = lead < 0xa0 ? 0x81 : 0xc1;
|
|
1326
|
-
|
|
1327
1030
|
if (inRange(bite, 0x40, 0x7e) || inRange(bite, 0x80, 0xfc)) pointer = (lead - lead_offset) * 188 + bite - offset;
|
|
1328
|
-
|
|
1329
1031
|
if (inRange(pointer, 8836, 10715)) return 0xe000 - 8836 + pointer;
|
|
1330
|
-
|
|
1331
1032
|
var code_point = pointer === null ? null : indexCodePointFor(pointer, index('jis0208'));
|
|
1332
|
-
|
|
1333
1033
|
if (code_point === null && isASCIIByte(bite)) stream.prepend(bite);
|
|
1334
|
-
|
|
1335
1034
|
if (code_point === null) return decoderError(fatal);
|
|
1336
|
-
|
|
1337
1035
|
return code_point;
|
|
1338
1036
|
}
|
|
1339
|
-
|
|
1340
1037
|
if (isASCIIByte(bite) || bite === 0x80) return bite;
|
|
1341
|
-
|
|
1342
1038
|
if (inRange(bite, 0xa1, 0xdf)) return 0xff61 - 0xa1 + bite;
|
|
1343
|
-
|
|
1344
1039
|
if (inRange(bite, 0x81, 0x9f) || inRange(bite, 0xe0, 0xfc)) {
|
|
1345
1040
|
Shift_JIS_lead = bite;
|
|
1346
1041
|
return null;
|
|
1347
1042
|
}
|
|
1348
|
-
|
|
1349
1043
|
return decoderError(fatal);
|
|
1350
1044
|
};
|
|
1351
1045
|
}
|
|
1352
|
-
|
|
1353
1046
|
function ShiftJISEncoder(options) {
|
|
1354
1047
|
var fatal = options.fatal;
|
|
1355
1048
|
this.handler = function (stream, code_point) {
|
|
1356
1049
|
if (code_point === end_of_stream) return finished;
|
|
1357
|
-
|
|
1358
1050
|
if (isASCIICodePoint(code_point) || code_point === 0x0080) return code_point;
|
|
1359
|
-
|
|
1360
1051
|
if (code_point === 0x00a5) return 0x5c;
|
|
1361
|
-
|
|
1362
1052
|
if (code_point === 0x203e) return 0x7e;
|
|
1363
|
-
|
|
1364
1053
|
if (inRange(code_point, 0xff61, 0xff9f)) return code_point - 0xff61 + 0xa1;
|
|
1365
|
-
|
|
1366
1054
|
if (code_point === 0x2212) code_point = 0xff0d;
|
|
1367
|
-
|
|
1368
1055
|
var pointer = indexShiftJISPointerFor(code_point);
|
|
1369
|
-
|
|
1370
1056
|
if (pointer === null) return encoderError(code_point);
|
|
1371
|
-
|
|
1372
1057
|
var lead = floor(pointer / 188);
|
|
1373
|
-
|
|
1374
1058
|
var lead_offset = lead < 0x1f ? 0x81 : 0xc1;
|
|
1375
|
-
|
|
1376
1059
|
var trail = pointer % 188;
|
|
1377
|
-
|
|
1378
1060
|
var offset = trail < 0x3f ? 0x40 : 0x41;
|
|
1379
|
-
|
|
1380
1061
|
return [lead + lead_offset, trail + offset];
|
|
1381
1062
|
};
|
|
1382
1063
|
}
|
|
1383
|
-
|
|
1384
1064
|
encoders['Shift_JIS'] = function (options) {
|
|
1385
1065
|
return new ShiftJISEncoder(options);
|
|
1386
1066
|
};
|
|
1387
1067
|
decoders['Shift_JIS'] = function (options) {
|
|
1388
1068
|
return new ShiftJISDecoder(options);
|
|
1389
1069
|
};
|
|
1390
|
-
|
|
1391
1070
|
function EUCKRDecoder(options) {
|
|
1392
1071
|
var fatal = options.fatal;
|
|
1393
|
-
|
|
1394
1072
|
var euckr_lead = 0x00;
|
|
1395
1073
|
this.handler = function (stream, bite) {
|
|
1396
1074
|
if (bite === end_of_stream && euckr_lead !== 0) {
|
|
1397
1075
|
euckr_lead = 0x00;
|
|
1398
1076
|
return decoderError(fatal);
|
|
1399
1077
|
}
|
|
1400
|
-
|
|
1401
1078
|
if (bite === end_of_stream && euckr_lead === 0) return finished;
|
|
1402
|
-
|
|
1403
1079
|
if (euckr_lead !== 0x00) {
|
|
1404
1080
|
var lead = euckr_lead;
|
|
1405
1081
|
var pointer = null;
|
|
1406
1082
|
euckr_lead = 0x00;
|
|
1407
|
-
|
|
1408
1083
|
if (inRange(bite, 0x41, 0xfe)) pointer = (lead - 0x81) * 190 + (bite - 0x41);
|
|
1409
|
-
|
|
1410
1084
|
var code_point = pointer === null ? null : indexCodePointFor(pointer, index('euc-kr'));
|
|
1411
|
-
|
|
1412
1085
|
if (pointer === null && isASCIIByte(bite)) stream.prepend(bite);
|
|
1413
|
-
|
|
1414
1086
|
if (code_point === null) return decoderError(fatal);
|
|
1415
|
-
|
|
1416
1087
|
return code_point;
|
|
1417
1088
|
}
|
|
1418
|
-
|
|
1419
1089
|
if (isASCIIByte(bite)) return bite;
|
|
1420
|
-
|
|
1421
1090
|
if (inRange(bite, 0x81, 0xfe)) {
|
|
1422
1091
|
euckr_lead = bite;
|
|
1423
1092
|
return null;
|
|
1424
1093
|
}
|
|
1425
|
-
|
|
1426
1094
|
return decoderError(fatal);
|
|
1427
1095
|
};
|
|
1428
1096
|
}
|
|
1429
|
-
|
|
1430
1097
|
function EUCKREncoder(options) {
|
|
1431
1098
|
var fatal = options.fatal;
|
|
1432
1099
|
this.handler = function (stream, code_point) {
|
|
1433
1100
|
if (code_point === end_of_stream) return finished;
|
|
1434
|
-
|
|
1435
1101
|
if (isASCIICodePoint(code_point)) return code_point;
|
|
1436
|
-
|
|
1437
1102
|
var pointer = indexPointerFor(code_point, index('euc-kr'));
|
|
1438
|
-
|
|
1439
1103
|
if (pointer === null) return encoderError(code_point);
|
|
1440
|
-
|
|
1441
1104
|
var lead = floor(pointer / 190) + 0x81;
|
|
1442
|
-
|
|
1443
1105
|
var trail = pointer % 190 + 0x41;
|
|
1444
|
-
|
|
1445
1106
|
return [lead, trail];
|
|
1446
1107
|
};
|
|
1447
1108
|
}
|
|
1448
|
-
|
|
1449
1109
|
encoders['EUC-KR'] = function (options) {
|
|
1450
1110
|
return new EUCKREncoder(options);
|
|
1451
1111
|
};
|
|
1452
1112
|
decoders['EUC-KR'] = function (options) {
|
|
1453
1113
|
return new EUCKRDecoder(options);
|
|
1454
1114
|
};
|
|
1455
|
-
|
|
1456
1115
|
function convertCodeUnitToBytes(code_unit, utf16be) {
|
|
1457
1116
|
var byte1 = code_unit >> 8;
|
|
1458
|
-
|
|
1459
1117
|
var byte2 = code_unit & 0x00ff;
|
|
1460
|
-
|
|
1461
1118
|
if (utf16be) return [byte1, byte2];
|
|
1462
1119
|
return [byte2, byte1];
|
|
1463
1120
|
}
|
|
1464
|
-
|
|
1465
1121
|
function UTF16Decoder(utf16_be, options) {
|
|
1466
1122
|
var fatal = options.fatal;
|
|
1467
1123
|
var utf16_lead_byte = null,
|
|
@@ -1470,16 +1126,13 @@ function UTF16Decoder(utf16_be, options) {
|
|
|
1470
1126
|
if (bite === end_of_stream && (utf16_lead_byte !== null || utf16_lead_surrogate !== null)) {
|
|
1471
1127
|
return decoderError(fatal);
|
|
1472
1128
|
}
|
|
1473
|
-
|
|
1474
1129
|
if (bite === end_of_stream && utf16_lead_byte === null && utf16_lead_surrogate === null) {
|
|
1475
1130
|
return finished;
|
|
1476
1131
|
}
|
|
1477
|
-
|
|
1478
1132
|
if (utf16_lead_byte === null) {
|
|
1479
1133
|
utf16_lead_byte = bite;
|
|
1480
1134
|
return null;
|
|
1481
1135
|
}
|
|
1482
|
-
|
|
1483
1136
|
var code_unit;
|
|
1484
1137
|
if (utf16_be) {
|
|
1485
1138
|
code_unit = (utf16_lead_byte << 8) + bite;
|
|
@@ -1487,89 +1140,67 @@ function UTF16Decoder(utf16_be, options) {
|
|
|
1487
1140
|
code_unit = (bite << 8) + utf16_lead_byte;
|
|
1488
1141
|
}
|
|
1489
1142
|
utf16_lead_byte = null;
|
|
1490
|
-
|
|
1491
1143
|
if (utf16_lead_surrogate !== null) {
|
|
1492
1144
|
var lead_surrogate = utf16_lead_surrogate;
|
|
1493
1145
|
utf16_lead_surrogate = null;
|
|
1494
|
-
|
|
1495
1146
|
if (inRange(code_unit, 0xdc00, 0xdfff)) {
|
|
1496
1147
|
return 0x10000 + (lead_surrogate - 0xd800) * 0x400 + (code_unit - 0xdc00);
|
|
1497
1148
|
}
|
|
1498
|
-
|
|
1499
1149
|
stream.prepend(convertCodeUnitToBytes(code_unit, utf16_be));
|
|
1500
1150
|
return decoderError(fatal);
|
|
1501
1151
|
}
|
|
1502
|
-
|
|
1503
1152
|
if (inRange(code_unit, 0xd800, 0xdbff)) {
|
|
1504
1153
|
utf16_lead_surrogate = code_unit;
|
|
1505
1154
|
return null;
|
|
1506
1155
|
}
|
|
1507
|
-
|
|
1508
1156
|
if (inRange(code_unit, 0xdc00, 0xdfff)) return decoderError(fatal);
|
|
1509
|
-
|
|
1510
1157
|
return code_unit;
|
|
1511
1158
|
};
|
|
1512
1159
|
}
|
|
1513
|
-
|
|
1514
1160
|
function UTF16Encoder(utf16_be, options) {
|
|
1515
1161
|
var fatal = options.fatal;
|
|
1516
1162
|
this.handler = function (stream, code_point) {
|
|
1517
1163
|
if (code_point === end_of_stream) return finished;
|
|
1518
|
-
|
|
1519
1164
|
if (inRange(code_point, 0x0000, 0xffff)) return convertCodeUnitToBytes(code_point, utf16_be);
|
|
1520
|
-
|
|
1521
1165
|
var lead = convertCodeUnitToBytes((code_point - 0x10000 >> 10) + 0xd800, utf16_be);
|
|
1522
|
-
|
|
1523
1166
|
var trail = convertCodeUnitToBytes((code_point - 0x10000 & 0x3ff) + 0xdc00, utf16_be);
|
|
1524
|
-
|
|
1525
1167
|
return lead.concat(trail);
|
|
1526
1168
|
};
|
|
1527
1169
|
}
|
|
1528
|
-
|
|
1529
1170
|
encoders['UTF-16BE'] = function (options) {
|
|
1530
1171
|
return new UTF16Encoder(true, options);
|
|
1531
1172
|
};
|
|
1532
1173
|
decoders['UTF-16BE'] = function (options) {
|
|
1533
1174
|
return new UTF16Decoder(true, options);
|
|
1534
1175
|
};
|
|
1535
|
-
|
|
1536
1176
|
encoders['UTF-16LE'] = function (options) {
|
|
1537
1177
|
return new UTF16Encoder(false, options);
|
|
1538
1178
|
};
|
|
1539
1179
|
decoders['UTF-16LE'] = function (options) {
|
|
1540
1180
|
return new UTF16Decoder(false, options);
|
|
1541
1181
|
};
|
|
1542
|
-
|
|
1543
1182
|
function XUserDefinedDecoder(options) {
|
|
1544
1183
|
var fatal = options.fatal;
|
|
1545
1184
|
this.handler = function (stream, bite) {
|
|
1546
1185
|
if (bite === end_of_stream) return finished;
|
|
1547
|
-
|
|
1548
1186
|
if (isASCIIByte(bite)) return bite;
|
|
1549
|
-
|
|
1550
1187
|
return 0xf780 + bite - 0x80;
|
|
1551
1188
|
};
|
|
1552
1189
|
}
|
|
1553
|
-
|
|
1554
1190
|
function XUserDefinedEncoder(options) {
|
|
1555
1191
|
var fatal = options.fatal;
|
|
1556
1192
|
this.handler = function (stream, code_point) {
|
|
1557
1193
|
if (code_point === end_of_stream) return finished;
|
|
1558
|
-
|
|
1559
1194
|
if (isASCIICodePoint(code_point)) return code_point;
|
|
1560
|
-
|
|
1561
1195
|
if (inRange(code_point, 0xf780, 0xf7ff)) return code_point - 0xf780 + 0x80;
|
|
1562
|
-
|
|
1563
1196
|
return encoderError(code_point);
|
|
1564
1197
|
};
|
|
1565
1198
|
}
|
|
1566
|
-
|
|
1567
1199
|
encoders['x-user-defined'] = function (options) {
|
|
1568
1200
|
return new XUserDefinedEncoder(options);
|
|
1569
1201
|
};
|
|
1570
1202
|
decoders['x-user-defined'] = function (options) {
|
|
1571
1203
|
return new XUserDefinedDecoder(options);
|
|
1572
1204
|
};
|
|
1573
|
-
|
|
1574
1205
|
export { TextEncoder, TextDecoder };
|
|
1575
1206
|
//# sourceMappingURL=encoding.js.map
|