Skip to content

Commit 7d82bcf

Browse files
committed
doc: a warning against single-byte/multi-byte abuse
1 parent 0e3427a commit 7d82bcf

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,15 @@ import { windows1252toString, windows1252fromString } from '@exodus/bytes/single
230230
import { latin1toString, latin1fromString } from '@exodus/bytes/single-byte.js'
231231
```
232232

233+
> [!WARNING]
234+
> This is a lower-level API for single-byte encodings.
235+
> It might not match what you expect, as it supports both WHATWG and unicode.org encodings under
236+
> different names, with the main intended usecase for the latter being either non-web or legacy contexts.
237+
>
238+
> For a safe WHATWG Encoding-compatible API, see `@exodus/bytes/encoding.js` import (and variants of it).
239+
>
240+
> Be sure to know what you are doing and check documentation when directly using encodings from this file.
241+
233242
Supports all single-byte encodings listed in the WHATWG Encoding standard:
234243
`ibm866`, `iso-8859-2`, `iso-8859-3`, `iso-8859-4`, `iso-8859-5`, `iso-8859-6`, `iso-8859-7`, `iso-8859-8`,
235244
`iso-8859-8-i`, `iso-8859-10`, `iso-8859-13`, `iso-8859-14`, `iso-8859-15`, `iso-8859-16`, `koi8-r`, `koi8-u`,
@@ -341,6 +350,13 @@ Decode / encode the legacy multi-byte encodings according to the
341350
import { createMultibyteDecoder, createMultibyteEncoder } from '@exodus/bytes/multi-byte.js'
342351
```
343352

353+
> [!WARNING]
354+
> This is a lower-level API for legacy multi-byte encodings.
355+
>
356+
> For a safe WHATWG Encoding-compatible API, see `@exodus/bytes/encoding.js` import (and variants of it).
357+
>
358+
> Be sure to know what you are doing and check documentation when directly using encodings from this file.
359+
344360
Supports all legacy multi-byte encodings listed in the WHATWG Encoding standard:
345361
`gbk`, `gb18030`, `big5`, `euc-jp`, `iso-2022-jp`, `shift_jis`, `euc-kr`.
346362

multi-byte.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
* import { createMultibyteDecoder, createMultibyteEncoder } from '@exodus/bytes/multi-byte.js'
1111
* ```
1212
*
13+
* > [!WARNING]
14+
* > This is a lower-level API for legacy multi-byte encodings.
15+
* >
16+
* > For a safe WHATWG Encoding-compatible API, see `@exodus/bytes/encoding.js` import (and variants of it).
17+
* >
18+
* > Be sure to know what you are doing and check documentation when directly using encodings from this file.
19+
*
1320
* Supports all legacy multi-byte encodings listed in the WHATWG Encoding standard:
1421
* `gbk`, `gb18030`, `big5`, `euc-jp`, `iso-2022-jp`, `shift_jis`, `euc-kr`.
1522
*

single-byte.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
* import { latin1toString, latin1fromString } from '@exodus/bytes/single-byte.js'
1212
* ```
1313
*
14+
* > [!WARNING]
15+
* > This is a lower-level API for single-byte encodings.
16+
* > It might not match what you expect, as it supports both WHATWG and unicode.org encodings under
17+
* > different names, with the main intended usecase for the latter being either non-web or legacy contexts.
18+
* >
19+
* > For a safe WHATWG Encoding-compatible API, see `@exodus/bytes/encoding.js` import (and variants of it).
20+
* >
21+
* > Be sure to know what you are doing and check documentation when directly using encodings from this file.
22+
*
1423
* Supports all single-byte encodings listed in the WHATWG Encoding standard:
1524
* `ibm866`, `iso-8859-2`, `iso-8859-3`, `iso-8859-4`, `iso-8859-5`, `iso-8859-6`, `iso-8859-7`, `iso-8859-8`,
1625
* `iso-8859-8-i`, `iso-8859-10`, `iso-8859-13`, `iso-8859-14`, `iso-8859-15`, `iso-8859-16`, `koi8-r`, `koi8-u`,

0 commit comments

Comments
 (0)