1

I'm trying to convert a fetch response from ISO-8859-1 to UTF-8 in react native. I found this answer : Encoding conversion of a fetch response but in react native i'm having some troubles...

I didn't manage to use iconv, i tryed :

npm install --save iconv-lite // success

then i do

var iconv = require('iconv-lite') // Error 500 from react native

I didn't manage to use Buffer, it is unknown by react native and

require('buffer').Buffer // Error 500 from react native

So here are my questions :

What is the best way to make an encoding conversion in react native ?
In case Encoding conversion of a fetch response is good: How do i use iconv ? How do i use Buffer ?

Community
  • 1
  • 1
alexandre
  • 195
  • 4
  • 15
  • have you checked this github thread already? https://github.com/ashtuchkin/iconv-lite/issues/150 – YaNuSH Jan 13 '19 at 01:35

1 Answers1

1

Please consider this code:

import iconv from "iconv-lite";
import {Buffer} from "buffer";

let str = iconv.decode(Buffer.from("hello"), 'us-ascii')
trocchietto
  • 2,607
  • 2
  • 23
  • 36