|
1 | 1 | /** |
2 | | - * Single-byte encoding/decoding |
3 | | - * |
4 | 2 | * ```js |
5 | 3 | * import { createSinglebyteDecoder, createSinglebyteEncoder } from '@exodus/bytes/single-byte.js' |
6 | | - * import { latin1toString, latin1fromString } from '@exodus/bytes/single-byte.js' |
7 | 4 | * import { windows1252toString, windows1252fromString } from '@exodus/bytes/single-byte.js' |
| 5 | + * import { latin1toString, latin1fromString } from '@exodus/bytes/single-byte.js' |
8 | 6 | * ``` |
9 | 7 | * |
10 | | - * Supports various single-byte character encodings like ISO-8859-* and Windows-125*. |
| 8 | + * Decode / encode the legacy single-byte encodings according to the |
| 9 | + * [Encoding standard](https://encoding.spec.whatwg.org/) |
| 10 | + * ([§9](https://encoding.spec.whatwg.org/#legacy-single-byte-encodings), |
| 11 | + * [§14.5](https://encoding.spec.whatwg.org/#x-user-defined)), |
| 12 | + * and [unicode.org](https://unicode.org/Public/MAPPINGS/ISO8859) `iso-8859-*` mappings. |
| 13 | + * |
| 14 | + * Supports all single-byte encodings listed in the WHATWG Encoding standard: |
| 15 | + * `ibm866`, `iso-8859-2`, `iso-8859-3`, `iso-8859-4`, `iso-8859-5`, `iso-8859-6`, `iso-8859-7`, `iso-8859-8`, |
| 16 | + * `iso-8859-8-i`, `iso-8859-10`, `iso-8859-13`, `iso-8859-14`, `iso-8859-15`, `iso-8859-16`, `koi8-r`, `koi8-u`, |
| 17 | + * `macintosh`, `windows-874`, `windows-1250`, `windows-1251`, `windows-1252`, `windows-1253`, `windows-1254`, |
| 18 | + * `windows-1255`, `windows-1256`, `windows-1257`, `windows-1258`, `x-mac-cyrillic` and `x-user-defined`. |
| 19 | + * |
| 20 | + * Also supports `iso-8859-1`, `iso-8859-9`, `iso-8859-11` as defined at |
| 21 | + * [unicode.org](https://unicode.org/Public/MAPPINGS/ISO8859) |
| 22 | + * (and all other `iso-8859-*` encodings there as they match WHATWG). |
| 23 | + * |
| 24 | + * > [!NOTE] |
| 25 | + * > While all `iso-8859-*` encodings supported by the [WHATWG Encoding standard](https://encoding.spec.whatwg.org/) match |
| 26 | + * > [unicode.org](https://unicode.org/Public/MAPPINGS/ISO8859), the WHATWG Encoding spec doesn't support |
| 27 | + * > `iso-8859-1`, `iso-8859-9`, `iso-8859-11`, and instead maps them as labels to `windows-1252`, `windows-1254`, `windows-874`.\ |
| 28 | + * > `createSinglebyteDecoder()` (unlike `TextDecoder` or `legacyHookDecode()`) does not do such mapping, |
| 29 | + * > so its results will differ from `TextDecoder` for those encoding names. |
11 | 30 | * |
12 | 31 | * @module @exodus/bytes/single-byte.js |
13 | 32 | */ |
|
0 commit comments