iconv-nano 0.0.0 → 0.0.2

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.
Files changed (83) hide show
  1. package/README.md +16 -3
  2. package/dist/codecs/big5.d.ts +8 -0
  3. package/dist/codecs/big5.js +39 -0
  4. package/dist/codecs/euc-kr.d.ts +8 -0
  5. package/dist/codecs/euc-kr.js +38 -0
  6. package/dist/codecs/gb18030.d.ts +8 -0
  7. package/dist/codecs/gb18030.js +92 -0
  8. package/dist/codecs/shift_jis.d.ts +8 -0
  9. package/dist/codecs/shift_jis.js +50 -0
  10. package/dist/codecs/single-byte/ibm866.d.ts +3 -3
  11. package/dist/codecs/single-byte/ibm866.js +3 -2
  12. package/dist/codecs/single-byte/iso-8859-10.d.ts +3 -3
  13. package/dist/codecs/single-byte/iso-8859-10.js +3 -2
  14. package/dist/codecs/single-byte/iso-8859-13.d.ts +3 -3
  15. package/dist/codecs/single-byte/iso-8859-13.js +3 -2
  16. package/dist/codecs/single-byte/iso-8859-14.d.ts +3 -3
  17. package/dist/codecs/single-byte/iso-8859-14.js +3 -2
  18. package/dist/codecs/single-byte/iso-8859-15.d.ts +3 -3
  19. package/dist/codecs/single-byte/iso-8859-15.js +3 -2
  20. package/dist/codecs/single-byte/iso-8859-16.d.ts +3 -3
  21. package/dist/codecs/single-byte/iso-8859-16.js +3 -2
  22. package/dist/codecs/single-byte/iso-8859-2.d.ts +3 -3
  23. package/dist/codecs/single-byte/iso-8859-2.js +3 -2
  24. package/dist/codecs/single-byte/iso-8859-3.d.ts +3 -3
  25. package/dist/codecs/single-byte/iso-8859-3.js +3 -2
  26. package/dist/codecs/single-byte/iso-8859-4.d.ts +3 -3
  27. package/dist/codecs/single-byte/iso-8859-4.js +3 -2
  28. package/dist/codecs/single-byte/iso-8859-5.d.ts +3 -3
  29. package/dist/codecs/single-byte/iso-8859-5.js +3 -2
  30. package/dist/codecs/single-byte/iso-8859-6.d.ts +3 -3
  31. package/dist/codecs/single-byte/iso-8859-6.js +3 -2
  32. package/dist/codecs/single-byte/iso-8859-7.d.ts +3 -3
  33. package/dist/codecs/single-byte/iso-8859-7.js +3 -2
  34. package/dist/codecs/single-byte/iso-8859-8-i.d.ts +3 -3
  35. package/dist/codecs/single-byte/iso-8859-8-i.js +3 -2
  36. package/dist/codecs/single-byte/iso-8859-8.d.ts +3 -3
  37. package/dist/codecs/single-byte/iso-8859-8.js +3 -2
  38. package/dist/codecs/single-byte/koi8-r.d.ts +3 -3
  39. package/dist/codecs/single-byte/koi8-r.js +3 -2
  40. package/dist/codecs/single-byte/koi8-u.d.ts +3 -3
  41. package/dist/codecs/single-byte/koi8-u.js +3 -2
  42. package/dist/codecs/single-byte/macintosh.d.ts +3 -3
  43. package/dist/codecs/single-byte/macintosh.js +3 -2
  44. package/dist/codecs/single-byte/windows-1250.d.ts +3 -3
  45. package/dist/codecs/single-byte/windows-1250.js +3 -2
  46. package/dist/codecs/single-byte/windows-1251.d.ts +3 -3
  47. package/dist/codecs/single-byte/windows-1251.js +3 -2
  48. package/dist/codecs/single-byte/windows-1252.d.ts +3 -3
  49. package/dist/codecs/single-byte/windows-1252.js +3 -2
  50. package/dist/codecs/single-byte/windows-1253.d.ts +3 -3
  51. package/dist/codecs/single-byte/windows-1253.js +3 -2
  52. package/dist/codecs/single-byte/windows-1254.d.ts +3 -3
  53. package/dist/codecs/single-byte/windows-1254.js +3 -2
  54. package/dist/codecs/single-byte/windows-1255.d.ts +3 -3
  55. package/dist/codecs/single-byte/windows-1255.js +3 -2
  56. package/dist/codecs/single-byte/windows-1256.d.ts +3 -3
  57. package/dist/codecs/single-byte/windows-1256.js +3 -2
  58. package/dist/codecs/single-byte/windows-1257.d.ts +3 -3
  59. package/dist/codecs/single-byte/windows-1257.js +3 -2
  60. package/dist/codecs/single-byte/windows-1258.d.ts +3 -3
  61. package/dist/codecs/single-byte/windows-1258.js +3 -2
  62. package/dist/codecs/single-byte/windows-874.d.ts +3 -3
  63. package/dist/codecs/single-byte/windows-874.js +3 -2
  64. package/dist/codecs/single-byte/x-mac-cyrillic.d.ts +3 -3
  65. package/dist/codecs/single-byte/x-mac-cyrillic.js +3 -2
  66. package/dist/codecs/utf-16.d.ts +12 -0
  67. package/dist/codecs/utf-16.js +36 -0
  68. package/dist/codecs/utf-16be.d.ts +8 -0
  69. package/dist/codecs/utf-16be.js +19 -0
  70. package/dist/codecs/utf-16le.d.ts +8 -0
  71. package/dist/codecs/utf-16le.js +19 -0
  72. package/dist/codecs/utf-8.d.ts +3 -3
  73. package/dist/codecs/utf-8.js +2 -1
  74. package/dist/encodings/big5.js +1 -0
  75. package/dist/encodings/euc-kr.js +1 -0
  76. package/dist/encodings/gb18030-ranges.js +1 -0
  77. package/dist/encodings/gb18030.js +1 -0
  78. package/dist/encodings/shift_jis.js +1 -0
  79. package/dist/index.d.ts +9 -2
  80. package/dist/index.js +9 -2
  81. package/dist/interfaces.d.ts +18 -1
  82. package/dist/utils/encodeSingleByteEncoding.js +8 -6
  83. package/package.json +49 -20
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  You probably shouldn't use this for now.
12
12
 
13
- I'm waiting on ESM [namespace imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#namespace_import) in Rolldown ([rolldown/rolldown#7874](https://github.com/rolldown/rolldown/issues/7874)) to be supported. It looks like it will be coming on Rolldown 1.4.
13
+ I'm waiting on ESM [namespace imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#namespace_import) in Rolldown ([rolldown/rolldown#7874](https://github.com/rolldown/rolldown/issues/7874)) to be supported. It looks like it will be coming on Rolldown 1.4. While tree-shaking will still work for encodings, the individual `encode`/`decode` functions cannot be treeshook until this is resolved.
14
14
 
15
15
  Documentation is avaliable at this URL: https://npmx.dev/package-docs/iconv-nano.
16
16
 
@@ -22,8 +22,14 @@ import * as iconv from "iconv-nano";
22
22
  iconv.utf8.encode("😅").toHex(); // "f09f9885"
23
23
  iconv.utf8.decode(Uint8Array.fromHex("f09f9885")); // "😅"
24
24
 
25
- iconv.ascii.encode("😅").toHex(); // "3f3f"
26
- iconv.ascii.decode(Uint8Array.fromHex("3f3f")); // "??"
25
+ iconv.ascii.encode("😅").toHex(); // "3f"
26
+ iconv.ascii.decode(Uint8Array.fromHex("3f")); // "?"
27
+
28
+ iconv.utf16.encode("😅", { endianness: "little-endian" }).toHex(); // "3dd805de"
29
+ iconv.utf16.decode(Uint8Array.fromHex("3dd805de")); // "😅"
30
+
31
+ iconv.shift_jis.encode("文字化け"); // "95b68e9a89bb82af"
32
+ iconv.shift_jis.decode(Uint8Array.fromHex("95b68e9a89bb82af")); // "文字化け"
27
33
  ```
28
34
 
29
35
  ## Supported encodings
@@ -57,6 +63,13 @@ iconv.ascii.decode(Uint8Array.fromHex("3f3f")); // "??"
57
63
  - windows-1257
58
64
  - windows-1258
59
65
  - x-mac-cyrillic
66
+ - utf-16
67
+ - utf-16be
68
+ - utf-16le
69
+ - Shift_JIS
70
+ - EUC-KR
71
+ - Big5
72
+ - gb18030
60
73
 
61
74
  ## License
62
75
 
@@ -0,0 +1,8 @@
1
+ import { Decoder, Encoder } from "../interfaces.js";
2
+ declare namespace big5_d_exports {
3
+ export { decode, encode };
4
+ }
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
+ //#endregion
8
+ export { big5_d_exports, decode, encode };
@@ -0,0 +1,39 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { getCachedTextDecoder } from "../utils/getCachedTextDecoder.js";
3
+ import big5_default from "../encodings/big5.js";
4
+
5
+ //#region src/codecs/big5.ts
6
+ var big5_exports = /* @__PURE__ */ __exportAll({
7
+ decode: () => decode,
8
+ encode: () => encode
9
+ });
10
+ const encode = (input) => {
11
+ const buf = new Uint8Array(input.length * 2);
12
+ let byteOffset = 0;
13
+ for (const char of input) {
14
+ let codePoint = char.codePointAt(0);
15
+ if (0 <= codePoint && codePoint <= 127) {
16
+ buf[byteOffset] = codePoint;
17
+ byteOffset++;
18
+ } else {
19
+ const pointer = big5_default[String.fromCodePoint(codePoint)];
20
+ const leading = Math.floor(pointer / 157) + 129;
21
+ const trailing = pointer % 157;
22
+ const offset = trailing < 63 ? 64 : 98;
23
+ buf[byteOffset] = leading;
24
+ buf[byteOffset + 1] = trailing + offset;
25
+ byteOffset += 2;
26
+ }
27
+ }
28
+ return buf.subarray(0, byteOffset);
29
+ };
30
+ const decode = (input, decodeOptions) => {
31
+ const stripBOM = decodeOptions?.stripBOM ?? true;
32
+ return getCachedTextDecoder("big5", {
33
+ fatal: false,
34
+ ignoreBOM: !stripBOM
35
+ }).decode(input);
36
+ };
37
+
38
+ //#endregion
39
+ export { big5_exports, decode, encode };
@@ -0,0 +1,8 @@
1
+ import { Decoder, Encoder } from "../interfaces.js";
2
+ declare namespace euc_kr_d_exports {
3
+ export { decode, encode };
4
+ }
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
+ //#endregion
8
+ export { decode, encode, euc_kr_d_exports };
@@ -0,0 +1,38 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { getCachedTextDecoder } from "../utils/getCachedTextDecoder.js";
3
+ import euc_kr_default from "../encodings/euc-kr.js";
4
+
5
+ //#region src/codecs/euc-kr.ts
6
+ var euc_kr_exports = /* @__PURE__ */ __exportAll({
7
+ decode: () => decode,
8
+ encode: () => encode
9
+ });
10
+ const encode = (input) => {
11
+ const buf = new Uint8Array(input.length * 2);
12
+ let byteOffset = 0;
13
+ for (const char of input) {
14
+ let codePoint = char.codePointAt(0);
15
+ if (0 <= codePoint && codePoint <= 127) {
16
+ buf[byteOffset] = codePoint;
17
+ byteOffset++;
18
+ } else {
19
+ const pointer = euc_kr_default[String.fromCodePoint(codePoint)];
20
+ const leading = Math.floor(pointer / 190) + 129;
21
+ const trailing = pointer % 190 + 65;
22
+ buf[byteOffset] = leading;
23
+ buf[byteOffset + 1] = trailing;
24
+ byteOffset += 2;
25
+ }
26
+ }
27
+ return buf.subarray(0, byteOffset);
28
+ };
29
+ const decode = (input, decodeOptions) => {
30
+ const stripBOM = decodeOptions?.stripBOM ?? true;
31
+ return getCachedTextDecoder("euc-kr", {
32
+ fatal: false,
33
+ ignoreBOM: !stripBOM
34
+ }).decode(input);
35
+ };
36
+
37
+ //#endregion
38
+ export { decode, encode, euc_kr_exports };
@@ -0,0 +1,8 @@
1
+ import { Decoder, Encoder } from "../interfaces.js";
2
+ declare namespace gb18030_d_exports {
3
+ export { decode, encode };
4
+ }
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
+ //#endregion
8
+ export { decode, encode, gb18030_d_exports };
@@ -0,0 +1,92 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { getCachedTextDecoder } from "../utils/getCachedTextDecoder.js";
3
+ import gb18030_ranges_default from "../encodings/gb18030-ranges.js";
4
+ import gb18030_default from "../encodings/gb18030.js";
5
+
6
+ //#region src/codecs/gb18030.ts
7
+ var gb18030_exports = /* @__PURE__ */ __exportAll({
8
+ decode: () => decode,
9
+ encode: () => encode
10
+ });
11
+ const TABLE = {
12
+ 59277: [166, 217],
13
+ 59278: [166, 218],
14
+ 59279: [166, 219],
15
+ 59280: [166, 220],
16
+ 59281: [166, 221],
17
+ 59282: [166, 222],
18
+ 59283: [166, 223],
19
+ 59284: [166, 236],
20
+ 59285: [166, 237],
21
+ 59286: [166, 243],
22
+ 59422: [254, 89],
23
+ 59430: [254, 97],
24
+ 59435: [254, 102],
25
+ 59436: [254, 103],
26
+ 59442: [254, 109],
27
+ 59459: [254, 126],
28
+ 59476: [254, 144],
29
+ 59492: [254, 160]
30
+ };
31
+ const getGb18030RangesPointer = (codePoint) => {
32
+ if (codePoint === 59335) return 7457;
33
+ let rangeIndex = void 0;
34
+ let [left, right] = [0, gb18030_ranges_default.length - 1];
35
+ while (left <= right) {
36
+ const mid = left + right >> 1;
37
+ if (gb18030_ranges_default[mid][1] <= codePoint) {
38
+ rangeIndex = mid;
39
+ left = mid + 1;
40
+ } else right = mid - 1;
41
+ }
42
+ if (rangeIndex === void 0) throw new Error("dfsifkj");
43
+ const [pointerOffset, codePointOffset] = gb18030_ranges_default[rangeIndex];
44
+ return pointerOffset + codePoint - codePointOffset;
45
+ };
46
+ const encode = (input) => {
47
+ const buf = new Uint8Array(input.length * 2);
48
+ let byteOffset = 0;
49
+ for (const char of input) {
50
+ let codePoint = char.codePointAt(0);
51
+ if (0 <= codePoint && codePoint <= 127) {
52
+ buf[byteOffset] = codePoint;
53
+ byteOffset++;
54
+ } else if (codePoint === 58853) continue;
55
+ else if (codePoint in TABLE) {
56
+ buf.set(TABLE[codePoint], byteOffset);
57
+ byteOffset += 2;
58
+ } else {
59
+ let pointer = gb18030_default[String.fromCodePoint(codePoint)];
60
+ if (pointer !== void 0) {
61
+ const leading = Math.floor(pointer / 190) + 129;
62
+ const trailing = pointer % 190;
63
+ const offset = trailing < 63 ? 64 : 65;
64
+ buf[byteOffset] = leading;
65
+ buf[byteOffset + 1] = trailing + offset;
66
+ byteOffset += 2;
67
+ }
68
+ pointer = getGb18030RangesPointer(codePoint);
69
+ const byte1 = Math.floor(pointer / 12600);
70
+ pointer = pointer % 12600;
71
+ const byte2 = Math.floor(pointer / 1260);
72
+ pointer = pointer % 1260;
73
+ const byte3 = pointer / 10;
74
+ const byte4 = pointer % 10;
75
+ buf[byteOffset] = byte1 + 129;
76
+ buf[byteOffset + 1] = byte2 + 48;
77
+ buf[byteOffset + 2] = byte3 + 129;
78
+ buf[byteOffset + 3] = byte4 + 48;
79
+ }
80
+ }
81
+ return buf.subarray(0, byteOffset);
82
+ };
83
+ const decode = (input, decodeOptions) => {
84
+ const stripBOM = decodeOptions?.stripBOM ?? true;
85
+ return getCachedTextDecoder("gb18030", {
86
+ fatal: false,
87
+ ignoreBOM: !stripBOM
88
+ }).decode(input);
89
+ };
90
+
91
+ //#endregion
92
+ export { decode, encode, gb18030_exports };
@@ -0,0 +1,8 @@
1
+ import { Decoder, Encoder } from "../interfaces.js";
2
+ declare namespace shift_jis_d_exports {
3
+ export { decode, encode };
4
+ }
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
+ //#endregion
8
+ export { decode, encode, shift_jis_d_exports };
@@ -0,0 +1,50 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { getCachedTextDecoder } from "../utils/getCachedTextDecoder.js";
3
+ import shift_jis_default from "../encodings/shift_jis.js";
4
+
5
+ //#region src/codecs/shift_jis.ts
6
+ var shift_jis_exports = /* @__PURE__ */ __exportAll({
7
+ decode: () => decode,
8
+ encode: () => encode
9
+ });
10
+ const encode = (input) => {
11
+ const buf = new Uint8Array(input.length * 2);
12
+ let byteOffset = 0;
13
+ for (const char of input) {
14
+ let codePoint = char.codePointAt(0);
15
+ if (0 <= codePoint && codePoint <= 127 || codePoint === 128) {
16
+ buf[byteOffset] = codePoint;
17
+ byteOffset++;
18
+ } else if (codePoint === 165) {
19
+ buf[byteOffset] = 92;
20
+ byteOffset++;
21
+ } else if (codePoint === 8254) {
22
+ buf[byteOffset] = 126;
23
+ byteOffset++;
24
+ } else if (65377 <= codePoint && codePoint <= 65439) {
25
+ buf[byteOffset] = codePoint - 65377 + 161;
26
+ byteOffset++;
27
+ } else {
28
+ if (codePoint === 8722) codePoint = 65293;
29
+ const pointer = shift_jis_default[String.fromCodePoint(codePoint)];
30
+ const leading = Math.floor(pointer / 188);
31
+ const leadingOffset = leading < 31 ? 129 : 193;
32
+ const trailing = pointer % 188;
33
+ const offset = trailing < 63 ? 64 : 65;
34
+ buf[byteOffset] = leading + leadingOffset;
35
+ buf[byteOffset + 1] = trailing + offset;
36
+ byteOffset += 2;
37
+ }
38
+ }
39
+ return buf.subarray(0, byteOffset);
40
+ };
41
+ const decode = (input, decodeOptions) => {
42
+ const stripBOM = decodeOptions?.stripBOM ?? true;
43
+ return getCachedTextDecoder("shift_jis", {
44
+ fatal: false,
45
+ ignoreBOM: !stripBOM
46
+ }).decode(input);
47
+ };
48
+
49
+ //#endregion
50
+ export { decode, encode, shift_jis_exports };
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace ibm866_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, ibm866_d_exports };
@@ -1,7 +1,7 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
+ import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
2
3
  import ibm866_default from "../../encodings/ibm866.js";
3
4
  import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
- import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
5
5
 
6
6
  //#region src/codecs/single-byte/ibm866.ts
7
7
  var ibm866_exports = /* @__PURE__ */ __exportAll({
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, ibm866_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("ibm866", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_10_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_10_d_exports };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
- import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
3
2
  import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
3
+ import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
4
  import iso_8859_10_default from "../../encodings/iso-8859-10.js";
5
5
 
6
6
  //#region src/codecs/single-byte/iso-8859-10.ts
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, iso_8859_10_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("iso-8859-10", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_13_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_13_d_exports };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
- import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
3
2
  import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
3
+ import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
4
  import iso_8859_13_default from "../../encodings/iso-8859-13.js";
5
5
 
6
6
  //#region src/codecs/single-byte/iso-8859-13.ts
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, iso_8859_13_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("iso-8859-13", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_14_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_14_d_exports };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
- import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
3
2
  import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
3
+ import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
4
  import iso_8859_14_default from "../../encodings/iso-8859-14.js";
5
5
 
6
6
  //#region src/codecs/single-byte/iso-8859-14.ts
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, iso_8859_14_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("iso-8859-14", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_15_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_15_d_exports };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
- import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
3
2
  import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
3
+ import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
4
  import iso_8859_15_default from "../../encodings/iso-8859-15.js";
5
5
 
6
6
  //#region src/codecs/single-byte/iso-8859-15.ts
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, iso_8859_15_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("iso-8859-15", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_16_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_16_d_exports };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
- import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
3
2
  import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
3
+ import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
4
  import iso_8859_16_default from "../../encodings/iso-8859-16.js";
5
5
 
6
6
  //#region src/codecs/single-byte/iso-8859-16.ts
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, iso_8859_16_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("iso-8859-16", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_2_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_2_d_exports };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
- import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
3
2
  import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
3
+ import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
4
  import iso_8859_2_default from "../../encodings/iso-8859-2.js";
5
5
 
6
6
  //#region src/codecs/single-byte/iso-8859-2.ts
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, iso_8859_2_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("iso-8859-2", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_3_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_3_d_exports };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
- import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
3
2
  import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
3
+ import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
4
  import iso_8859_3_default from "../../encodings/iso-8859-3.js";
5
5
 
6
6
  //#region src/codecs/single-byte/iso-8859-3.ts
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, iso_8859_3_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("iso-8859-3", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_4_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_4_d_exports };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
- import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
3
2
  import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
3
+ import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
4
  import iso_8859_4_default from "../../encodings/iso-8859-4.js";
5
5
 
6
6
  //#region src/codecs/single-byte/iso-8859-4.ts
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, iso_8859_4_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("iso-8859-4", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_5_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_5_d_exports };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
- import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
3
2
  import { getCachedTextDecoder } from "../../utils/getCachedTextDecoder.js";
3
+ import { encodeSingleByteEncoding } from "../../utils/encodeSingleByteEncoding.js";
4
4
  import iso_8859_5_default from "../../encodings/iso-8859-5.js";
5
5
 
6
6
  //#region src/codecs/single-byte/iso-8859-5.ts
@@ -12,9 +12,10 @@ const encode = (input) => {
12
12
  return encodeSingleByteEncoding(input, iso_8859_5_default);
13
13
  };
14
14
  const decode = (input, decodeOptions) => {
15
+ const stripBOM = decodeOptions?.stripBOM ?? true;
15
16
  return getCachedTextDecoder("iso-8859-5", {
16
17
  fatal: false,
17
- ignoreBOM: decodeOptions?.stripBOM ?? true
18
+ ignoreBOM: !stripBOM
18
19
  }).decode(input);
19
20
  };
20
21
 
@@ -1,8 +1,8 @@
1
- import { BufferSource, DecodeOptions } from "../../interfaces.js";
1
+ import { Decoder, Encoder } from "../../interfaces.js";
2
2
  declare namespace iso_8859_6_d_exports {
3
3
  export { decode, encode };
4
4
  }
5
- declare const encode: (input: string) => Uint8Array<ArrayBuffer>;
6
- declare const decode: (input: BufferSource, decodeOptions?: DecodeOptions) => string;
5
+ declare const encode: Encoder;
6
+ declare const decode: Decoder;
7
7
  //#endregion
8
8
  export { decode, encode, iso_8859_6_d_exports };