15

I'm currently making a website using ReactJS and webpack to build it.

My text editor is set on ISO-8859-15 encoding and I'm using accented or special chars like é è à ç.

In my html page, I believe I'm using the right configuration:

<meta charset="iso-8859-15">

But special chars are not rendered the right way: Fran�ais instead of Français for instance.

I tried to set charset="utf-8" but nothing changed.

I feel like webpack is building with UTF-8 encoding, which brakes my chars. How could I fix this issue?

3 Answers 3

10

I didn't find a way to make webpack read input files with an encoding other than UTF-8. I had to set up my project to write source files in UTF-8, and then used webpack-encoding-plugin to output files as ISO-8859-1 or whatever. It worked.

2
  • 1
    I confirm this is the only solution I found so far. For whoever is using visualstudio this is how to save the file in utf-8 msdn.microsoft.com/en-us/library/dxfdkfke.aspx Commented May 31, 2017 at 18:44
  • This solution works for accent characters into utf-8 sources. But if react render data from an rest service in ISO-8859-1 the accent characters still to be wrong. Commented Sep 16, 2020 at 11:23
0

To fix fetch problems with not utf-8 endpoints this is the solution:

fetch(url)
    .then(response => response.arrayBuffer())
    .then(buffer => {
      let decoder = new TextDecoder('iso-8859-1');
      return decoder.decode(buffer);
    })
    .then(res => JSON.parse(res))
-2

I solved by changing the .js file encoding format to UTF8. I just oppened the file with Notepad ++ and I did: Format -> Converto to UTF8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.