using TextDecoder with hermes
Problem
TextEncoder was recently added with 3863a36a53005dd1e6d39ea0d4ef5573bafde910 (related issue #948), but there doesn't seem to be a TextDecoder added. It seems odd that the encoder was added without the related decoder.
Solution
Add TextDecoder to hermes.
Hi, is this planned?
It is planned, but not very high priority. PRs are welcome.
hi @tmikov is there a plan to release a TextDecoder?
Having this issue in react-native 0.74. Workaround is to use import 'fast-text-encoder in every layout which uses an import which deals with TextDecoder.
Is there a fix for this in the near future? I have seen the cpp code for TextEncoder and there is no way for me to contribute to this with my knowledge of cpp. I'm using Effect HttpClient which uses TextDecoder.
Eagerly awaiting for TextDecoder 🧘
hi @tmikov do we know when it will be in?
I'm also waiting for this :/ Does anybody know how to find out which package depends on TextDecoder? I only get this error here:
ReferenceError: Property 'TextDecoder' doesn't exist, js engine: hermes
I don't know where it comes from 🙈
@heybuild
You have two options to polyfill the TextDecoder API:
- https://github.com/inexorabletash/text-encoding
- https://github.com/maksimlya/react-native-fast-encoder
I've written a short guide on how to use one of them to enable streaming in React Native (Expo): 👉 https://gist.github.com/aretrace/bcb0777c2cfd2b0b1d9dcfb805fe2838
@heybuild You have two options to polyfill the
TextDecoderAPI:
- https://github.com/inexorabletash/text-encoding
- https://github.com/maksimlya/react-native-fast-encoder
I've written a short guide on how to use one of them to enable streaming in React Native (Expo): 👉 https://gist.github.com/aretrace/bcb0777c2cfd2b0b1d9dcfb805fe2838
Thank you! This did the trick:
// index.ts
import "fast-text-encoding";
import "expo-router/entry";
You have two options to polyfill the
TextDecoderAPI:
Hi @aretrace ,
I have the same TextDecoder issue. When I use TextDecoder('latin1') in my ReactNative code, it causes error: Unknown encoding: latin1.
I tried to polyfill using react-native-fast-encoder and fast-text-encoding in my App.ts, but it didn't work.
if (typeof global.TextEncoder === 'undefined') {
global.TextEncoder = TextEncoder
}
if (typeof global.TextDecoder === 'undefined') {
global.TextDecoder = TextDecoder
}
I did not use the TextDecode directly in my own code, it's a thirdparty library I dependent use TextDecode. Should I modify the thirdparty library, do the polyfill?