@react-native-quickjs/text-encoding
v1.0.1
Published
Native TextEncoder and TextDecoder for react-native-quickjs
Downloads
311
Maintainers
Readme
@react-native-quickjs/text-encoding
TextEncoder and TextDecoder, per WHATWG Encoding, as direct QuickJS bindings.
Hermes provides both, so an app moving to QuickJS expects them. Without them a
bundle either carries a JavaScript polyfill -- the encoder is a per-character
loop over a growing array -- or fails outright: Expo's development client reads
TextEncoder while loading, before any app code runs.
@react-native-quickjs/quickjs depends on this package, so an app gets it
without asking.
Behaviour worth knowing
- An unpaired surrogate encodes as U+FFFD; it is not an error.
- A leading byte order mark is stripped unless
ignoreBOMis set. fatal: truethrows aTypeErroron ill-formed input; otherwise ill-formed sequences decode to U+FFFD.encodeIntostops on a character boundary, so a destination too small for the next character consumes nothing rather than writing a partial sequence.
