Add barcode-detector-api-polyfill dependency and update environment variable declarations in SvelteKit project
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
/** @const */ export declare const DEFAULT_ENCODING = "utf-8";
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/** @const */ export const DEFAULT_ENCODING = 'utf-8';
|
||||
//# sourceMappingURL=defaultEncoding.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defaultEncoding.js","sourceRoot":"","sources":["../../../src/encoding/defaultEncoding.ts"],"names":[],"mappings":"AACA,aAAa,CAAC,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { Decoder } from '../common/Decoder';
|
||||
import { Encoder } from '../common/Encoder';
|
||||
declare type XCoderFactory<Tncoder = Encoder | Decoder> = ({ fatal: boolean }: {
|
||||
fatal: any;
|
||||
}) => Tncoder;
|
||||
declare type Encoders = {
|
||||
[s: string]: XCoderFactory<Encoder>;
|
||||
};
|
||||
declare type Decoders = {
|
||||
[s: string]: XCoderFactory<Decoder>;
|
||||
};
|
||||
/** @type {Object.<string, function({fatal:boolean}): Encoder>} */
|
||||
/** @type {Object.<string, function({fatal:boolean}): Decoder>} */
|
||||
export declare const encoders: Encoders;
|
||||
export declare const decoders: Decoders;
|
||||
export {};
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// See LICENSE.md for more information.
|
||||
import { Big5Decoder, Big5Encoder } from '../coders/big5';
|
||||
import { EUCJPDecoder, EUCJPEncoder } from '../coders/euc-jp';
|
||||
import { EUCKRDecoder, EUCKREncoder } from '../coders/euc-kr';
|
||||
import { GB18030Decoder, GB18030Encoder } from '../coders/gb18030';
|
||||
import { ISO2022JPDecoder, ISO2022JPEncoder } from '../coders/iso-2022-jp';
|
||||
import { ShiftJISDecoder, ShiftJISEncoder } from '../coders/shift-jis';
|
||||
import { SingleByteDecoder, SingleByteEncoder } from '../coders/single-byte';
|
||||
import { UTF16Decoder, UTF16Encoder } from '../coders/utf-16';
|
||||
import { UTF8Decoder, UTF8Encoder } from '../coders/utf-8';
|
||||
import { XUserDefinedDecoder, XUserDefinedEncoder } from '../coders/x-user-defined';
|
||||
import { encodings } from './encodings';
|
||||
import { index } from './indexes';
|
||||
import { getEncodingIndexes } from './encoding-indexes-provider';
|
||||
//
|
||||
// Utilities
|
||||
//
|
||||
// import './encoding/utilities';
|
||||
//
|
||||
// Implementation of Encoding specification
|
||||
// https://encoding.spec.whatwg.org/
|
||||
//
|
||||
//
|
||||
// 4. Terminology
|
||||
//
|
||||
// import './encoding/terminology';
|
||||
//
|
||||
// 5. Encodings
|
||||
//
|
||||
// import "./encoding/encodings";
|
||||
//
|
||||
// 6. Indexes
|
||||
//
|
||||
// import './encoding/indexes';
|
||||
const encodingIndexes = getEncodingIndexes();
|
||||
// Registry of of encoder/decoder factories, by encoding name.
|
||||
/** @type {Object.<string, function({fatal:boolean}): Encoder>} */
|
||||
// const encoders: Encoders = {};
|
||||
/** @type {Object.<string, function({fatal:boolean}): Decoder>} */
|
||||
// const decoders: Decoders = {};
|
||||
//
|
||||
// 10. Legacy single-byte encodings
|
||||
//
|
||||
// 10.1 single-byte decoder
|
||||
// 10.2 single-byte encoder
|
||||
export const encoders = {
|
||||
// 9.1 utf-8
|
||||
// 9.1.1 utf-8 decoder
|
||||
// 9.1.2 utf-8 encoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'UTF-8': (options) => new UTF8Encoder(options),
|
||||
//
|
||||
// 11. Legacy multi-byte Chinese (simplified) encodings
|
||||
//
|
||||
// 11.1 gbk
|
||||
// 11.1.1 gbk decoder
|
||||
// gbk's decoder is gb18030's decoder.
|
||||
// 11.1.2 gbk encoder
|
||||
// gbk's encoder is gb18030's encoder with its gbk flag set.
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'GBK': (options) => new GB18030Encoder(options, true),
|
||||
// 11.2 gb18030
|
||||
// 11.2.1 gb18030 decoder
|
||||
// 11.2.2 gb18030 encoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'gb18030': (options) => new GB18030Encoder(options),
|
||||
//
|
||||
// 12. Legacy multi-byte Chinese (traditional) encodings
|
||||
//
|
||||
// 12.1 Big5
|
||||
// 12.1.1 Big5 decoder
|
||||
// 12.1.2 Big5 encoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'Big5': (options) => new Big5Encoder(options),
|
||||
//
|
||||
// 13. Legacy multi-byte Japanese encodings
|
||||
//
|
||||
// 13.1 euc-jp
|
||||
// 13.1.1 euc-jp decoder
|
||||
// 13.1.2 euc-jp encoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'EUC-JP': (options) => new EUCJPEncoder(options),
|
||||
// 13.2 iso-2022-jp
|
||||
// 13.2.1 iso-2022-jp decoder
|
||||
// 13.2.2 iso-2022-jp encoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'ISO-2022-JP': (options) => new ISO2022JPEncoder(options),
|
||||
// 13.3 Shift_JIS
|
||||
// 13.3.1 Shift_JIS decoder
|
||||
// 13.3.2 Shift_JIS encoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'Shift_JIS': (options) => new ShiftJISEncoder(options),
|
||||
//
|
||||
// 14. Legacy multi-byte Korean encodings
|
||||
//
|
||||
// 14.1 euc-kr
|
||||
// 14.1.1 euc-kr decoder
|
||||
// 14.1.2 euc-kr encoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'EUC-KR': (options) => new EUCKREncoder(options),
|
||||
//
|
||||
// 15. Legacy miscellaneous encodings
|
||||
//
|
||||
// 15.1 replacement
|
||||
// Not needed - API throws RangeError
|
||||
// 15.2 Common infrastructure for utf-16be and utf-16le
|
||||
// 15.2.1 shared utf-16 decoder
|
||||
// 15.2.2 shared utf-16 encoder
|
||||
// 15.3 utf-16be
|
||||
// 15.3.1 utf-16be decoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'UTF-16BE': (options) => new UTF16Encoder(true, options),
|
||||
// 15.3.2 utf-16be encoder
|
||||
// 15.4 utf-16le
|
||||
// 15.4.1 utf-16le decoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'UTF-16LE': (options) => new UTF16Encoder(false, options),
|
||||
// 15.4.2 utf-16le encoder
|
||||
// 15.5 x-user-defined
|
||||
// 15.5.1 x-user-defined decoder
|
||||
// 15.5.2 x-user-defined encoder
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'x-user-defined': (options) => new XUserDefinedEncoder(options),
|
||||
};
|
||||
export const decoders = {
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'UTF-8': (options) => new UTF8Decoder(options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'GBK': (options) => new GB18030Decoder(options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'gb18030': (options) => new GB18030Decoder(options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'Big5': (options) => new Big5Decoder(options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'EUC-JP': (options) => new EUCJPDecoder(options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'ISO-2022-JP': (options) => new ISO2022JPDecoder(options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'Shift_JIS': (options) => new ShiftJISDecoder(options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'EUC-KR': (options) => new EUCKRDecoder(options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'UTF-16BE': (options) => new UTF16Decoder(true, options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'UTF-16LE': (options) => new UTF16Decoder(false, options),
|
||||
/** @param {{fatal: boolean}} options */
|
||||
'x-user-defined': (options) => new XUserDefinedDecoder(options),
|
||||
};
|
||||
if (encodingIndexes) {
|
||||
encodings.forEach(function (category) {
|
||||
if (category.heading !== 'Legacy single-byte encodings')
|
||||
return;
|
||||
category.encodings.forEach(function (encoding) {
|
||||
const name = encoding.name;
|
||||
const idx = index(name.toLowerCase());
|
||||
/** @param {{fatal: boolean}} options */
|
||||
decoders[name] = function (options) {
|
||||
return new SingleByteDecoder(idx, options);
|
||||
};
|
||||
/** @param {{fatal: boolean}} options */
|
||||
encoders[name] = function (options) {
|
||||
return new SingleByteEncoder(idx, options);
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=encoding-factory.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"encoding-factory.js","sourceRoot":"","sources":["../../../src/encoding/encoding-factory.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uCAAuC;AAEvC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,EAAE;AACF,YAAY;AACZ,EAAE;AAEF,iCAAiC;AAEjC,EAAE;AACF,2CA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WAAW,EAAE,CAAC,CAAC;YACtC,wCAAwC;YACxC,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,OAA4B;gBACrD,OAAO,IAAI,iBAAiB,CAAC,GAAe,EAAE,OAAO,CAAC,CAAC;YACzD,CAAC,CAAC;YACF,wCAAwC;YACxC,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,OAA4B;gBACrD,OAAO,IAAI,iBAAiB,CAAC,GAAe,EAAE,OAAO,CAAC,CAAC;YACzD,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export declare type EncodingIndexMap = {
|
||||
[x: string]: number[];
|
||||
};
|
||||
export declare function getEncodingIndexes(): EncodingIndexMap;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { getGlobalScope } from "../helper/getGlobalScope";
|
||||
let _encodingIndexes;
|
||||
function checkForEncodingIndexes() {
|
||||
if (typeof TextEncodingIndexes !== 'undefined')
|
||||
return TextEncodingIndexes.encodingIndexes;
|
||||
const glo = getGlobalScope();
|
||||
if (!glo)
|
||||
return null;
|
||||
if ('TextEncodingIndexes' in glo)
|
||||
return global['TextEncodingIndexes']['encodingIndexes'];
|
||||
if ('encoding-indexes' in glo)
|
||||
return global['encodingIndexes'];
|
||||
return null;
|
||||
}
|
||||
export function getEncodingIndexes() {
|
||||
if (_encodingIndexes) {
|
||||
return _encodingIndexes;
|
||||
}
|
||||
const indexes = checkForEncodingIndexes();
|
||||
if (!indexes) {
|
||||
return null;
|
||||
}
|
||||
_encodingIndexes = indexes;
|
||||
return indexes;
|
||||
}
|
||||
//# sourceMappingURL=encoding-indexes-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"encoding-indexes-provider.js","sourceRoot":"","sources":["../../../src/encoding/encoding-indexes-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAS1D,IAAI,gBAAkC,CAAC;AAEvC,SAAS,uBAAuB;IAE9B,IAAI,OAAO,mBAAmB,KAAK,WAAW;QAC5C,OAAO,mBAAmB,CAAC,eAAe,CAAC;IAE7C,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAE7B,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IAEtB,IAAI,qBAAqB,IAAI,GAAG;QAC9B,OAAO,MAAM,CAAC,qBAAqB,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAE1D,IAAI,kBAAkB,IAAI,GAAG;QAC3B,OAAO,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAEnC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kBAAkB;IAEhC,IAAI,gBAAgB,EAAE;QACpB,OAAO,gBAAgB,CAAC;KACzB;IAED,MAAM,OAAO,GAAG,uBAAuB,EAAE,CAAC;IAE1C,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,gBAAgB,GAAG,OAAO,CAAC;IAE3B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @param {boolean} fatal If true, decoding errors raise an exception.
|
||||
* @param {number=} opt_code_point Override the standard fallback code point.
|
||||
* @return {number} The code point to insert on a decoding error.
|
||||
*/
|
||||
export declare function decoderError(fatal: boolean, opt_code_point?: number | undefined): number;
|
||||
/**
|
||||
* @param {number} code_point The code point that could not be encoded.
|
||||
* @return {number} Always throws, no value is actually returned.
|
||||
*/
|
||||
export declare function encoderError(code_point: number): number;
|
||||
/**
|
||||
* @param {string} label The encoding label.
|
||||
* @return {?{name:string,labels:Array.<string>}}
|
||||
*/
|
||||
export declare function getEncoding(label: string): {
|
||||
name: string;
|
||||
labels: Array<string>;
|
||||
} | null;
|
||||
/**
|
||||
* Encodings table: https://encoding.spec.whatwg.org/encodings.json
|
||||
* @const
|
||||
* @type {!Array.<{
|
||||
* heading: string,
|
||||
* encodings: Array.<{name:string,labels:Array.<string>}>
|
||||
* }>}
|
||||
*/
|
||||
declare const encodings: {
|
||||
heading: string;
|
||||
encodings: {
|
||||
name: string;
|
||||
labels: string[];
|
||||
}[];
|
||||
}[];
|
||||
export { encodings };
|
||||
+425
@@ -0,0 +1,425 @@
|
||||
/**
|
||||
* @param {boolean} fatal If true, decoding errors raise an exception.
|
||||
* @param {number=} opt_code_point Override the standard fallback code point.
|
||||
* @return {number} The code point to insert on a decoding error.
|
||||
*/
|
||||
export function decoderError(fatal, opt_code_point = undefined) {
|
||||
if (fatal)
|
||||
throw TypeError("Decoder error");
|
||||
return opt_code_point || 0xfffd;
|
||||
}
|
||||
/**
|
||||
* @param {number} code_point The code point that could not be encoded.
|
||||
* @return {number} Always throws, no value is actually returned.
|
||||
*/
|
||||
export function encoderError(code_point) {
|
||||
throw TypeError("The code point " + code_point + " could not be encoded.");
|
||||
}
|
||||
// 5.2 Names and labels
|
||||
// TODO: Define @typedef for Encoding: {name:string,labels:Array.<string>}
|
||||
// https://github.com/google/closure-compiler/issues/247
|
||||
/**
|
||||
* @param {string} label The encoding label.
|
||||
* @return {?{name:string,labels:Array.<string>}}
|
||||
*/
|
||||
export function getEncoding(label) {
|
||||
// 1. Remove any leading and trailing ASCII whitespace from label.
|
||||
const keyLabel = String(label).trim().toLowerCase();
|
||||
// 2. If label is an ASCII case-insensitive match for any of the
|
||||
// labels listed in the table below, return the corresponding
|
||||
// encoding, and failure otherwise.
|
||||
if (keyLabel in label_to_encoding) {
|
||||
return label_to_encoding[keyLabel];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Encodings table: https://encoding.spec.whatwg.org/encodings.json
|
||||
* @const
|
||||
* @type {!Array.<{
|
||||
* heading: string,
|
||||
* encodings: Array.<{name:string,labels:Array.<string>}>
|
||||
* }>}
|
||||
*/
|
||||
const encodings = [
|
||||
{
|
||||
encodings: [
|
||||
{
|
||||
labels: ["unicode-1-1-utf-8", "utf-8", "utf8"],
|
||||
name: "UTF-8",
|
||||
},
|
||||
],
|
||||
heading: "The Encoding",
|
||||
},
|
||||
{
|
||||
encodings: [
|
||||
{
|
||||
labels: ["866", "cp866", "csibm866", "ibm866"],
|
||||
name: "IBM866",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"csisolatin2",
|
||||
"iso-8859-2",
|
||||
"iso-ir-101",
|
||||
"iso8859-2",
|
||||
"iso88592",
|
||||
"iso_8859-2",
|
||||
"iso_8859-2:1987",
|
||||
"l2",
|
||||
"latin2",
|
||||
],
|
||||
name: "ISO-8859-2",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"csisolatin3",
|
||||
"iso-8859-3",
|
||||
"iso-ir-109",
|
||||
"iso8859-3",
|
||||
"iso88593",
|
||||
"iso_8859-3",
|
||||
"iso_8859-3:1988",
|
||||
"l3",
|
||||
"latin3",
|
||||
],
|
||||
name: "ISO-8859-3",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"csisolatin4",
|
||||
"iso-8859-4",
|
||||
"iso-ir-110",
|
||||
"iso8859-4",
|
||||
"iso88594",
|
||||
"iso_8859-4",
|
||||
"iso_8859-4:1988",
|
||||
"l4",
|
||||
"latin4",
|
||||
],
|
||||
name: "ISO-8859-4",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"csisolatincyrillic",
|
||||
"cyrillic",
|
||||
"iso-8859-5",
|
||||
"iso-ir-144",
|
||||
"iso8859-5",
|
||||
"iso88595",
|
||||
"iso_8859-5",
|
||||
"iso_8859-5:1988",
|
||||
],
|
||||
name: "ISO-8859-5",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"arabic",
|
||||
"asmo-708",
|
||||
"csiso88596e",
|
||||
"csiso88596i",
|
||||
"csisolatinarabic",
|
||||
"ecma-114",
|
||||
"iso-8859-6",
|
||||
"iso-8859-6-e",
|
||||
"iso-8859-6-i",
|
||||
"iso-ir-127",
|
||||
"iso8859-6",
|
||||
"iso88596",
|
||||
"iso_8859-6",
|
||||
"iso_8859-6:1987",
|
||||
],
|
||||
name: "ISO-8859-6",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"csisolatingreek",
|
||||
"ecma-118",
|
||||
"elot_928",
|
||||
"greek",
|
||||
"greek8",
|
||||
"iso-8859-7",
|
||||
"iso-ir-126",
|
||||
"iso8859-7",
|
||||
"iso88597",
|
||||
"iso_8859-7",
|
||||
"iso_8859-7:1987",
|
||||
"sun_eu_greek",
|
||||
],
|
||||
name: "ISO-8859-7",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"csiso88598e",
|
||||
"csisolatinhebrew",
|
||||
"hebrew",
|
||||
"iso-8859-8",
|
||||
"iso-8859-8-e",
|
||||
"iso-ir-138",
|
||||
"iso8859-8",
|
||||
"iso88598",
|
||||
"iso_8859-8",
|
||||
"iso_8859-8:1988",
|
||||
"visual",
|
||||
],
|
||||
name: "ISO-8859-8",
|
||||
},
|
||||
{
|
||||
labels: ["csiso88598i", "iso-8859-8-i", "logical"],
|
||||
name: "ISO-8859-8-I",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"csisolatin6",
|
||||
"iso-8859-10",
|
||||
"iso-ir-157",
|
||||
"iso8859-10",
|
||||
"iso885910",
|
||||
"l6",
|
||||
"latin6",
|
||||
],
|
||||
name: "ISO-8859-10",
|
||||
},
|
||||
{
|
||||
labels: ["iso-8859-13", "iso8859-13", "iso885913"],
|
||||
name: "ISO-8859-13",
|
||||
},
|
||||
{
|
||||
labels: ["iso-8859-14", "iso8859-14", "iso885914"],
|
||||
name: "ISO-8859-14",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"csisolatin9",
|
||||
"iso-8859-15",
|
||||
"iso8859-15",
|
||||
"iso885915",
|
||||
"iso_8859-15",
|
||||
"l9",
|
||||
],
|
||||
name: "ISO-8859-15",
|
||||
},
|
||||
{
|
||||
labels: ["iso-8859-16"],
|
||||
name: "ISO-8859-16",
|
||||
},
|
||||
{
|
||||
labels: ["cskoi8r", "koi", "koi8", "koi8-r", "koi8_r"],
|
||||
name: "KOI8-R",
|
||||
},
|
||||
{
|
||||
labels: ["koi8-ru", "koi8-u"],
|
||||
name: "KOI8-U",
|
||||
},
|
||||
{
|
||||
labels: ["csmacintosh", "mac", "macintosh", "x-mac-roman"],
|
||||
name: "macintosh",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"dos-874",
|
||||
"iso-8859-11",
|
||||
"iso8859-11",
|
||||
"iso885911",
|
||||
"tis-620",
|
||||
"windows-874",
|
||||
],
|
||||
name: "windows-874",
|
||||
},
|
||||
{
|
||||
labels: ["cp1250", "windows-1250", "x-cp1250"],
|
||||
name: "windows-1250",
|
||||
},
|
||||
{
|
||||
labels: ["cp1251", "windows-1251", "x-cp1251"],
|
||||
name: "windows-1251",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"ansi_x3.4-1968",
|
||||
"cp1252",
|
||||
"cp819",
|
||||
"ibm819",
|
||||
"iso-ir-100",
|
||||
"windows-1252",
|
||||
"x-cp1252",
|
||||
],
|
||||
name: "windows-1252",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"ascii",
|
||||
"us-ascii",
|
||||
"iso-8859-1",
|
||||
"iso8859-1",
|
||||
"iso88591",
|
||||
"iso_8859-1",
|
||||
"iso_8859-1:1987",
|
||||
"l1",
|
||||
"latin1",
|
||||
"csisolatin1",
|
||||
],
|
||||
name: "iso-8859-1",
|
||||
},
|
||||
{
|
||||
labels: ["cp1253", "windows-1253", "x-cp1253"],
|
||||
name: "windows-1253",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"cp1254",
|
||||
"csisolatin5",
|
||||
"iso-8859-9",
|
||||
"iso-ir-148",
|
||||
"iso8859-9",
|
||||
"iso88599",
|
||||
"iso_8859-9",
|
||||
"iso_8859-9:1989",
|
||||
"l5",
|
||||
"latin5",
|
||||
"windows-1254",
|
||||
"x-cp1254",
|
||||
],
|
||||
name: "windows-1254",
|
||||
},
|
||||
{
|
||||
labels: ["cp1255", "windows-1255", "x-cp1255"],
|
||||
name: "windows-1255",
|
||||
},
|
||||
{
|
||||
labels: ["cp1256", "windows-1256", "x-cp1256"],
|
||||
name: "windows-1256",
|
||||
},
|
||||
{
|
||||
labels: ["cp1257", "windows-1257", "x-cp1257"],
|
||||
name: "windows-1257",
|
||||
},
|
||||
{
|
||||
labels: ["cp1258", "windows-1258", "x-cp1258"],
|
||||
name: "windows-1258",
|
||||
},
|
||||
{
|
||||
labels: ["x-mac-cyrillic", "x-mac-ukrainian"],
|
||||
name: "x-mac-cyrillic",
|
||||
},
|
||||
],
|
||||
heading: "Legacy single-byte encodings",
|
||||
},
|
||||
{
|
||||
encodings: [
|
||||
{
|
||||
labels: [
|
||||
"chinese",
|
||||
"csgb2312",
|
||||
"csiso58gb231280",
|
||||
"gb2312",
|
||||
"gb_2312",
|
||||
"gb_2312-80",
|
||||
"gbk",
|
||||
"iso-ir-58",
|
||||
"x-gbk",
|
||||
],
|
||||
name: "GBK",
|
||||
},
|
||||
{
|
||||
labels: ["gb18030"],
|
||||
name: "gb18030",
|
||||
},
|
||||
],
|
||||
heading: "Legacy multi-byte Chinese (simplified) encodings",
|
||||
},
|
||||
{
|
||||
encodings: [
|
||||
{
|
||||
labels: ["big5", "big5-hkscs", "cn-big5", "csbig5", "x-x-big5"],
|
||||
name: "Big5",
|
||||
},
|
||||
],
|
||||
heading: "Legacy multi-byte Chinese (traditional) encodings",
|
||||
},
|
||||
{
|
||||
encodings: [
|
||||
{
|
||||
labels: ["cseucpkdfmtjapanese", "euc-jp", "x-euc-jp"],
|
||||
name: "EUC-JP",
|
||||
},
|
||||
{
|
||||
labels: ["csiso2022jp", "iso-2022-jp"],
|
||||
name: "ISO-2022-JP",
|
||||
},
|
||||
{
|
||||
labels: [
|
||||
"csshiftjis",
|
||||
"ms932",
|
||||
"ms_kanji",
|
||||
"shift-jis",
|
||||
"shift_jis",
|
||||
"sjis",
|
||||
"windows-31j",
|
||||
"x-sjis",
|
||||
],
|
||||
name: "Shift_JIS",
|
||||
},
|
||||
],
|
||||
heading: "Legacy multi-byte Japanese encodings",
|
||||
},
|
||||
{
|
||||
encodings: [
|
||||
{
|
||||
labels: [
|
||||
"cseuckr",
|
||||
"csksc56011987",
|
||||
"euc-kr",
|
||||
"iso-ir-149",
|
||||
"korean",
|
||||
"ks_c_5601-1987",
|
||||
"ks_c_5601-1989",
|
||||
"ksc5601",
|
||||
"ksc_5601",
|
||||
"windows-949",
|
||||
],
|
||||
name: "EUC-KR",
|
||||
},
|
||||
],
|
||||
heading: "Legacy multi-byte Korean encodings",
|
||||
},
|
||||
{
|
||||
encodings: [
|
||||
{
|
||||
labels: [
|
||||
"csiso2022kr",
|
||||
"hz-gb-2312",
|
||||
"iso-2022-cn",
|
||||
"iso-2022-cn-ext",
|
||||
"iso-2022-kr",
|
||||
],
|
||||
name: "replacement",
|
||||
},
|
||||
{
|
||||
labels: ["utf-16be"],
|
||||
name: "UTF-16BE",
|
||||
},
|
||||
{
|
||||
labels: ["utf-16", "utf-16le"],
|
||||
name: "UTF-16LE",
|
||||
},
|
||||
{
|
||||
labels: ["x-user-defined"],
|
||||
name: "x-user-defined",
|
||||
},
|
||||
],
|
||||
heading: "Legacy miscellaneous encodings",
|
||||
},
|
||||
];
|
||||
// Label to encoding registry.
|
||||
/** @type {Object.<string,{name:string,labels:Array.<string>}>} */
|
||||
const label_to_encoding = {};
|
||||
encodings.forEach((category) => {
|
||||
category.encodings.forEach((encoding) => {
|
||||
encoding.labels.forEach((label) => {
|
||||
label_to_encoding[label] = encoding;
|
||||
});
|
||||
});
|
||||
});
|
||||
export { encodings };
|
||||
//# sourceMappingURL=encodings.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+2
@@ -0,0 +1,2 @@
|
||||
/** @const */
|
||||
export declare const finished = -1;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// 5.1 Encoders and decoders
|
||||
/** @const */
|
||||
export const finished = -1;
|
||||
//# sourceMappingURL=finished.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"finished.js","sourceRoot":"","sources":["../../../src/encoding/finished.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,aAAa;AACb,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC"}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @param {number} pointer The |pointer| to search for.
|
||||
* @param {(!Array.<?number>|undefined)} index The |index| to search within.
|
||||
* @return {?number} The code point corresponding to |pointer| in |index|,
|
||||
* or null if |code point| is not in |index|.
|
||||
*/
|
||||
export declare function indexCodePointFor(pointer: number, index: (Array<number | null> | undefined)): number | null;
|
||||
/**
|
||||
* @param {number} code_point The |code point| to search for.
|
||||
* @param {!Array.<?number>} index The |index| to search within.
|
||||
* @return {?number} The first pointer corresponding to |code point| in
|
||||
* |index|, or null if |code point| is not in |index|.
|
||||
*/
|
||||
export declare function indexPointerFor(code_point: number, index: Array<number | null>): number | null;
|
||||
/**
|
||||
* @param {string} name Name of the index.
|
||||
* @return {(!Array.<number>|!Array.<Array.<number>>)}
|
||||
* */
|
||||
export declare function index(name: string): number[] | number[][];
|
||||
/**
|
||||
* @param {number} pointer The |pointer| to search for in the gb18030 index.
|
||||
* @return {?number} The code point corresponding to |pointer| in |index|,
|
||||
* or null if |code point| is not in the gb18030 index.
|
||||
*/
|
||||
export declare function indexGB18030RangesCodePointFor(pointer: number): number | null;
|
||||
/**
|
||||
* @param {number} code_point The |code point| to locate in the gb18030 index.
|
||||
* @return {number} The first pointer corresponding to |code point| in the
|
||||
* gb18030 index.
|
||||
*/
|
||||
export declare function indexGB18030RangesPointerFor(code_point: number): number;
|
||||
/**
|
||||
* @param {number} code_point The |code_point| to search for in the Shift_JIS
|
||||
* index.
|
||||
* @return {?number} The code point corresponding to |pointer| in |index|,
|
||||
* or null if |code point| is not in the Shift_JIS index.
|
||||
*/
|
||||
export declare function indexShiftJISPointerFor(code_point: number): number | null;
|
||||
/**
|
||||
* @param {number} code_point The |code_point| to search for in the big5
|
||||
* index.
|
||||
* @return {?number} The code point corresponding to |pointer| in |index|,
|
||||
* or null if |code point| is not in the big5 index.
|
||||
*/
|
||||
export declare function indexBig5PointerFor(code_point: number): number | null;
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
import { getArrayVal } from "../helper/getArrayVal";
|
||||
import { inRange } from "./utilities";
|
||||
import { getEncodingIndexes } from "./encoding-indexes-provider";
|
||||
/**
|
||||
* @param {number} pointer The |pointer| to search for.
|
||||
* @param {(!Array.<?number>|undefined)} index The |index| to search within.
|
||||
* @return {?number} The code point corresponding to |pointer| in |index|,
|
||||
* or null if |code point| is not in |index|.
|
||||
*/
|
||||
export function indexCodePointFor(pointer, index) {
|
||||
if (!index)
|
||||
return null;
|
||||
return index[pointer] || null;
|
||||
}
|
||||
/**
|
||||
* @param {number} code_point The |code point| to search for.
|
||||
* @param {!Array.<?number>} index The |index| to search within.
|
||||
* @return {?number} The first pointer corresponding to |code point| in
|
||||
* |index|, or null if |code point| is not in |index|.
|
||||
*/
|
||||
export function indexPointerFor(code_point, index) {
|
||||
const pointer = index.indexOf(code_point);
|
||||
return pointer === -1 ? null : pointer;
|
||||
}
|
||||
/**
|
||||
* @param {string} name Name of the index.
|
||||
* @return {(!Array.<number>|!Array.<Array.<number>>)}
|
||||
* */
|
||||
export function index(name) {
|
||||
const encodingIndexes = getEncodingIndexes();
|
||||
if (!encodingIndexes) {
|
||||
throw Error("Indexes missing." +
|
||||
" Did you forget to include encoding-indexes.js first?");
|
||||
}
|
||||
return encodingIndexes[name];
|
||||
}
|
||||
/**
|
||||
* @param {number} pointer The |pointer| to search for in the gb18030 index.
|
||||
* @return {?number} The code point corresponding to |pointer| in |index|,
|
||||
* or null if |code point| is not in the gb18030 index.
|
||||
*/
|
||||
export function indexGB18030RangesCodePointFor(pointer) {
|
||||
// 1. If pointer is greater than 39419 and less than 189000, or
|
||||
// pointer is greater than 1237575, return null.
|
||||
if ((pointer > 39419 && pointer < 189000) || (pointer > 1237575))
|
||||
return null;
|
||||
// 2. If pointer is 7457, return code point U+E7C7.
|
||||
if (pointer === 7457)
|
||||
return 0xE7C7;
|
||||
// 3. Let offset be the last pointer in index gb18030 ranges that
|
||||
// is equal to or less than pointer and let code point offset be
|
||||
// its corresponding code point.
|
||||
let offset = 0;
|
||||
let code_point_offset = 0;
|
||||
const idx = index('gb18030-ranges');
|
||||
for (let i = 0; i < idx.length; ++i) {
|
||||
/** @type {!Array.<number>} */
|
||||
const entry = getArrayVal(idx[i]);
|
||||
if (entry[0] <= pointer) {
|
||||
offset = entry[0];
|
||||
code_point_offset = entry[1];
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 4. Return a code point whose value is code point offset +
|
||||
// pointer − offset.
|
||||
return code_point_offset + pointer - offset;
|
||||
}
|
||||
/**
|
||||
* @param {number} code_point The |code point| to locate in the gb18030 index.
|
||||
* @return {number} The first pointer corresponding to |code point| in the
|
||||
* gb18030 index.
|
||||
*/
|
||||
export function indexGB18030RangesPointerFor(code_point) {
|
||||
// 1. If code point is U+E7C7, return pointer 7457.
|
||||
if (code_point === 0xE7C7)
|
||||
return 7457;
|
||||
// 2. Let offset be the last code point in index gb18030 ranges
|
||||
// that is equal to or less than code point and let pointer offset
|
||||
// be its corresponding pointer.
|
||||
let offset = 0;
|
||||
let pointer_offset = 0;
|
||||
const idx = index('gb18030-ranges');
|
||||
for (let i = 0; i < idx.length; ++i) {
|
||||
const idxVal = idx[i];
|
||||
/** @type {!Array.<number>} */
|
||||
const entry = getArrayVal(idxVal);
|
||||
if (entry[1] <= code_point) {
|
||||
offset = entry[1];
|
||||
pointer_offset = entry[0];
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 3. Return a pointer whose value is pointer offset + code point
|
||||
// − offset.
|
||||
return pointer_offset + code_point - offset;
|
||||
}
|
||||
/**
|
||||
* @param {number} code_point The |code_point| to search for in the Shift_JIS
|
||||
* index.
|
||||
* @return {?number} The code point corresponding to |pointer| in |index|,
|
||||
* or null if |code point| is not in the Shift_JIS index.
|
||||
*/
|
||||
export function indexShiftJISPointerFor(code_point) {
|
||||
// 1. Let index be index jis0208 excluding all entries whose
|
||||
// pointer is in the range 8272 to 8835, inclusive.
|
||||
shift_jis_index = shift_jis_index ||
|
||||
index('jis0208').map(function (code_point, pointer) {
|
||||
return inRange(pointer, 8272, 8835) ? null : code_point;
|
||||
});
|
||||
const index_ = shift_jis_index;
|
||||
// 2. Return the index pointer for code point in index.
|
||||
return index_.indexOf(code_point);
|
||||
}
|
||||
let shift_jis_index;
|
||||
/**
|
||||
* @param {number} code_point The |code_point| to search for in the big5
|
||||
* index.
|
||||
* @return {?number} The code point corresponding to |pointer| in |index|,
|
||||
* or null if |code point| is not in the big5 index.
|
||||
*/
|
||||
export function indexBig5PointerFor(code_point) {
|
||||
// 1. Let index be index Big5 excluding all entries whose pointer
|
||||
big5_index_no_hkscs = big5_index_no_hkscs ||
|
||||
index('big5').map((code_point, pointer) => (pointer < (0xA1 - 0x81) * 157) ? null : code_point);
|
||||
const index_ = big5_index_no_hkscs;
|
||||
// 2. If code point is U+2550, U+255E, U+2561, U+256A, U+5341, or
|
||||
// U+5345, return the last pointer corresponding to code point in
|
||||
// index.
|
||||
if (code_point === 0x2550 || code_point === 0x255E ||
|
||||
code_point === 0x2561 || code_point === 0x256A ||
|
||||
code_point === 0x5341 || code_point === 0x5345) {
|
||||
return index_.lastIndexOf(code_point);
|
||||
}
|
||||
// 3. Return the index pointer for code point in index.
|
||||
return indexPointerFor(code_point, index_);
|
||||
}
|
||||
let big5_index_no_hkscs;
|
||||
//# sourceMappingURL=indexes.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"indexes.js","sourceRoot":"","sources":["../../../src/encoding/indexes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,a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TextDecoder } from "../common/TextDecoder";
|
||||
import { TextEncoder } from "../common/TextEncoder";
|
||||
if (!global['TextEncoder'])
|
||||
global['TextEncoder'] = TextEncoder;
|
||||
if (!global['TextDecoder'])
|
||||
global['TextDecoder'] = TextDecoder;
|
||||
//# sourceMappingURL=polyfill.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../../src/encoding/polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACxB,MAAM,CAAC,aAAa,CAAC,GAAG,WAAW,CAAC;AACtC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACxB,MAAM,CAAC,aAAa,CAAC,GAAG,WAAW,CAAC"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* An ASCII byte is a byte in the range 0x00 to 0x7F, inclusive.
|
||||
* @param {number} a The number to test.
|
||||
* @return {boolean} True if a is in the range 0x00 to 0x7F, inclusive.
|
||||
*/
|
||||
export declare function isASCIIByte(a: number): boolean;
|
||||
/**
|
||||
* An ASCII code point is a code point in the range U+0000 to
|
||||
* U+007F, inclusive.
|
||||
*/
|
||||
export declare const isASCIICodePoint: typeof isASCIIByte;
|
||||
/**
|
||||
* End-of-stream is a special token that signifies no more tokens
|
||||
* are in the stream.
|
||||
* @const
|
||||
*/ export declare const end_of_stream = -1;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Implementation of Encoding specification
|
||||
// https://encoding.spec.whatwg.org/
|
||||
//
|
||||
//
|
||||
// 4. Terminology
|
||||
//
|
||||
/**
|
||||
* An ASCII byte is a byte in the range 0x00 to 0x7F, inclusive.
|
||||
* @param {number} a The number to test.
|
||||
* @return {boolean} True if a is in the range 0x00 to 0x7F, inclusive.
|
||||
*/
|
||||
export function isASCIIByte(a) {
|
||||
return 0x00 <= a && a <= 0x7F;
|
||||
}
|
||||
/**
|
||||
* An ASCII code point is a code point in the range U+0000 to
|
||||
* U+007F, inclusive.
|
||||
*/
|
||||
export const isASCIICodePoint = isASCIIByte;
|
||||
/**
|
||||
* End-of-stream is a special token that signifies no more tokens
|
||||
* are in the stream.
|
||||
* @const
|
||||
*/ export const end_of_stream = -1;
|
||||
//# sourceMappingURL=terminology.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"terminology.js","sourceRoot":"","sources":["../../../src/encoding/terminology.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,2CAA2C;AAC3C,oCAAoC;AACpC,EAAE;AAEF,EAAE;AACF,iBAAiB;AACjB,EAAE;AAEF;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,CAAS;IACnC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAG5C;;;;GAIG,CAAC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,CAAC"}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @param {number} a The number to test.
|
||||
* @param {number} min The minimum value in the range, inclusive.
|
||||
* @param {number} max The maximum value in the range, inclusive.
|
||||
* @return {boolean} True if a >= min and a <= max.
|
||||
*/
|
||||
export declare function inRange(a: number, min: number, max: number): boolean;
|
||||
/**
|
||||
* @param {!Array.<*>} array The array to check.
|
||||
* @param {*} item The item to look for in the array.
|
||||
* @return {boolean} True if the item appears in the array.
|
||||
*/
|
||||
export declare function includes(array: Array<any>, item: any): boolean;
|
||||
/**
|
||||
* @param {*} o
|
||||
* @return {Object}
|
||||
*/
|
||||
export declare function ToDictionary(o: any): {
|
||||
[x: string]: any;
|
||||
};
|
||||
/**
|
||||
* @param {string} string Input string of UTF-16 code units.
|
||||
* @return {!Array.<number>} Code points.
|
||||
*/
|
||||
export declare function stringToCodePoints(string: string): Array<number>;
|
||||
/**
|
||||
* @param {!Array.<number>} code_points Array of code points.
|
||||
* @return {string} string String of UTF-16 code units.
|
||||
*/
|
||||
export declare function codePointsToString(code_points: Array<number>): string;
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* @param {number} a The number to test.
|
||||
* @param {number} min The minimum value in the range, inclusive.
|
||||
* @param {number} max The maximum value in the range, inclusive.
|
||||
* @return {boolean} True if a >= min and a <= max.
|
||||
*/
|
||||
export function inRange(a, min, max) {
|
||||
return min <= a && a <= max;
|
||||
}
|
||||
/**
|
||||
* @param {!Array.<*>} array The array to check.
|
||||
* @param {*} item The item to look for in the array.
|
||||
* @return {boolean} True if the item appears in the array.
|
||||
*/
|
||||
export function includes(array, item) {
|
||||
return array.indexOf(item) !== -1;
|
||||
}
|
||||
/**
|
||||
* @param {*} o
|
||||
* @return {Object}
|
||||
*/
|
||||
export function ToDictionary(o) {
|
||||
if (o === undefined || o === null)
|
||||
return {};
|
||||
if (o === Object(o))
|
||||
return o;
|
||||
throw TypeError('Could not convert argument to dictionary');
|
||||
}
|
||||
/**
|
||||
* @param {string} string Input string of UTF-16 code units.
|
||||
* @return {!Array.<number>} Code points.
|
||||
*/
|
||||
export function stringToCodePoints(string) {
|
||||
// https://heycam.github.io/webidl/#dfn-obtain-unicode
|
||||
// 1. Let S be the DOMString value.
|
||||
const s = String(string);
|
||||
// 2. Let n be the length of S.
|
||||
const n = s.length;
|
||||
// 3. Initialize i to 0.
|
||||
let i = 0;
|
||||
// 4. Initialize U to be an empty sequence of Unicode characters.
|
||||
const u = [];
|
||||
// 5. While i < n:
|
||||
while (i < n) {
|
||||
// 1. Let c be the code unit in S at index i.
|
||||
const c = s.charCodeAt(i);
|
||||
// 2. Depending on the value of c:
|
||||
// c < 0xD800 or c > 0xDFFF
|
||||
if (c < 0xD800 || c > 0xDFFF) {
|
||||
// Append to U the Unicode character with code point c.
|
||||
u.push(c);
|
||||
}
|
||||
// 0xDC00 ≤ c ≤ 0xDFFF
|
||||
else if (0xDC00 <= c && c <= 0xDFFF) {
|
||||
// Append to U a U+FFFD REPLACEMENT CHARACTER.
|
||||
u.push(0xFFFD);
|
||||
}
|
||||
// 0xD800 ≤ c ≤ 0xDBFF
|
||||
else if (0xD800 <= c && c <= 0xDBFF) {
|
||||
// 1. If i = n−1, then append to U a U+FFFD REPLACEMENT
|
||||
// CHARACTER.
|
||||
if (i === n - 1) {
|
||||
u.push(0xFFFD);
|
||||
}
|
||||
// 2. Otherwise, i < n−1:
|
||||
else {
|
||||
// 1. Let d be the code unit in S at index i+1.
|
||||
const d = s.charCodeAt(i + 1);
|
||||
// 2. If 0xDC00 ≤ d ≤ 0xDFFF, then:
|
||||
if (0xDC00 <= d && d <= 0xDFFF) {
|
||||
// 1. Let a be c & 0x3FF.
|
||||
const a = c & 0x3FF;
|
||||
// 2. Let b be d & 0x3FF.
|
||||
const b = d & 0x3FF;
|
||||
// 3. Append to U the Unicode character with code point
|
||||
// 2^16+2^10*a+b.
|
||||
u.push(0x10000 + (a << 10) + b);
|
||||
// 4. Set i to i+1.
|
||||
i += 1;
|
||||
}
|
||||
// 3. Otherwise, d < 0xDC00 or d > 0xDFFF. Append to U a
|
||||
// U+FFFD REPLACEMENT CHARACTER.
|
||||
else {
|
||||
u.push(0xFFFD);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 3. Set i to i+1.
|
||||
i += 1;
|
||||
}
|
||||
// 6. Return U.
|
||||
return u;
|
||||
}
|
||||
/**
|
||||
* @param {!Array.<number>} code_points Array of code points.
|
||||
* @return {string} string String of UTF-16 code units.
|
||||
*/
|
||||
export function codePointsToString(code_points) {
|
||||
let s = '';
|
||||
for (let i = 0; i < code_points.length; ++i) {
|
||||
let cp = code_points[i];
|
||||
if (cp <= 0xFFFF) {
|
||||
s += String.fromCharCode(cp);
|
||||
}
|
||||
else {
|
||||
cp -= 0x10000;
|
||||
s += String.fromCharCode((cp >> 10) + 0xD800, (cp & 0x3FF) + 0xDC00);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
//# sourceMappingURL=utilities.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../src/encoding/utilities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IACzD,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAiB,EAAE,IAAS;IACnD,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,CAAM;IACjC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAC7C,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,SAAS,CAAC,0CAA0C,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,sDAAsD;IAEtD,mCAAmC;IACnC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAEzB,+BAA+B;IAC/B,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAEnB,wBAAwB;IACxB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,iEAAiE;IACjE,MAAM,CAAC,GAAG,EAAE,CAAC;IAEb,kBAAkB;IAClB,OAAO,CAAC,GAAG,CAAC,EAAE;QAEZ,6CAA6C;QAC7C,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAE1B,kCAAkC;QAElC,2BA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