示例:
以下字符串在 json.js 文件中定义。
var test = "One complimentary entrée with the purchase of an entrée.";
它被包含在一个index.html文件中
<script type="text/JavaScript" src="./json.js"></script>
当字符串显示在 UI 中时,它显示为
"One complimentary entr�e with the purchase of an entr�e."
但如果直接在index.html中定义string,那么就不是问题。
任何人都可以建议如何将文本保留在单独的 .js 文件中的解决方案吗?
最佳答案
将非拉丁字符转义为 HTML 实体,Éeacute;或者更改您的开发系统和代码编辑器的所有方面,以将所有文本字符解析为 UTF8。
关于javascript - 如果在单独的 javascript 文件中定义,则 "entrée"中的特殊字符无法正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2746682/