问题描述
我目前正在使用ReactJS和webpack来构建网站。
I'm currently making a website using ReactJS and webpack to build it.
我的文本编辑器设置为 ISO-8859-15
编码,而我使用的是带有重音或特殊字符的字符,例如éèàç
。
My text editor is set on ISO-8859-15
encoding and I'm using accented or special chars like é è à ç
.
在我的html页面中,我认为我使用的配置正确:
In my html page, I believe I'm using the right configuration:
<meta charset="iso-8859-15">
但是特殊字符的渲染方式不正确:
Fran ais
而不是Français
。
But special chars are not rendered the right way:Fran�ais
instead of Français
for instance.
我尝试设置 charset = utf-8
但没有任何变化。
I tried to set charset="utf-8"
but nothing changed.
我觉得webpack正在使用 UTF构建-8
编码,这会破坏我的字符。我该如何解决这个问题?
I feel like webpack is building with UTF-8
encoding, which brakes my chars. How could I fix this issue?
推荐答案
我没有找到一种方法使Webpack读取除编码以外的其他输入文件UTF-8。我必须设置项目以UTF-8格式编写源文件,然后使用可以将文件输出为ISO-8859-1或其他格式。可行。
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.
这篇关于React + Webpack字符编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!