@@ -344,6 +344,9 @@ const latin1toString = createSinglebyteDecoder('iso-8859-1')
344344> This is different from ` new TextDecoder('iso-8859-1') ` and ` new TextDecoder('latin1') ` , as those
345345> alias to ` new TextDecoder('windows-1252') ` .
346346
347+ Prefer using ` isomorphicDecode() ` from ` @exodus/bytes/encoding.js ` or ` @exodus/bytes/encoding-lite.js ` ,
348+ which is identical to this but allows more input types.
349+
347350#### ` latin1fromString(string) `
348351
349352Encode a string to ` iso-8859-1 ` bytes.
@@ -355,6 +358,8 @@ Same as:
355358const latin1fromString = createSinglebyteEncoder (' iso-8859-1' , { mode: ' fatal' })
356359```
357360
361+ Prefer using ` isomorphicEncode() ` from ` @exodus/bytes/encoding.js ` or ` @exodus/bytes/encoding-lite.js ` .
362+
358363#### ` windows1252toString(arr) `
359364
360365Decode ` windows-1252 ` bytes to a string.
@@ -714,6 +719,7 @@ some [hooks](https://encoding.spec.whatwg.org/#specification-hooks).
714719``` js
715720import { TextDecoder , TextEncoder } from ' @exodus/bytes/encoding.js'
716721import { TextDecoderStream , TextEncoderStream } from ' @exodus/bytes/encoding.js' // Requires Streams
722+ import { isomorphicDecode , isomorphicEncode } from ' @exodus/bytes/encoding.js'
717723
718724// Hooks for standards
719725import { getBOMEncoding , legacyHookDecode , labelToName , normalizeEncoding } from ' @exodus/bytes/encoding.js'
@@ -749,6 +755,26 @@ A [Streams](https://streams.spec.whatwg.org/) wrapper for `TextEncoder`.
749755Requires [ Streams] ( https://streams.spec.whatwg.org/ ) to be either supported by the platform or
750756[ polyfilled] ( https://npmjs.com/package/web-streams-polyfill ) .
751757
758+ #### ` isomorphicDecode(input) `
759+
760+ Implements [ isomorphic decode] ( https://infra.spec.whatwg.org/#isomorphic-decode ) .
761+
762+ Given a ` TypedArray ` or an ` ArrayBuffer ` instance ` input ` , creates a string of the same length
763+ as input byteLength, using bytes from input as codepoints.
764+
765+ E.g. for ` Uint8Array ` input, this is similar to ` String.fromCodePoint(...input) ` .
766+
767+ Wider ` TypedArray ` inputs, e.g. ` Uint16Array ` , are interpreted as underlying _ bytes_ .
768+
769+ #### ` isomorphicEncode(str) `
770+
771+ Implements [ isomorphic encode] ( https://infra.spec.whatwg.org/#isomorphic-encode ) .
772+
773+ Given a string, creates an ` Uint8Array ` of the same length with the string codepoints as byte values.
774+
775+ Accepts only [ isomorphic string] ( https://infra.spec.whatwg.org/#isomorphic-string ) input
776+ and asserts that, throwing on any strings containing codepoints higher than ` U+00FF ` .
777+
752778#### ` labelToName(label) `
753779
754780Implements [ get an encoding from a string ` label ` ] ( https://encoding.spec.whatwg.org/#concept-encoding-get ) .
@@ -822,6 +848,7 @@ multi-byte `TextDecoder` encodings by default to reduce bundle size ~12x.
822848` ` ` js
823849import { TextDecoder , TextEncoder } from ' @exodus/bytes/encoding-lite.js'
824850import { TextDecoderStream , TextEncoderStream } from ' @exodus/bytes/encoding-lite.js' // Requires Streams
851+ import { isomorphicDecode , isomorphicEncode } from ' @exodus/bytes/encoding-lite.js'
825852
826853// Hooks for standards
827854import { getBOMEncoding , legacyHookDecode , labelToName , normalizeEncoding } from ' @exodus/bytes/encoding-lite.js'
877904Same as ` @exodus/ bytes/ encoding .js ` , but in browsers instead of polyfilling just uses whatever the
878905browser provides, drastically reducing the bundle size (to less than 2 KiB gzipped).
879906
907+ Does not provide ` isomorphicDecode` and ` isomorphicEncode` exports.
908+
880909` ` ` js
881910import { TextDecoder , TextEncoder } from ' @exodus/bytes/encoding-browser.js'
882911import { TextDecoderStream , TextEncoderStream } from ' @exodus/bytes/encoding-browser.js' // Requires Streams
0 commit comments