json文件中的特殊字符 [英] Special Characters in json file
问题描述
所以我尝试使用Google的功能添加到主屏幕功能,而我试图让我的网络应用程序的标题显示一个特殊的字符,但不知道如何。
So i'm trying out googles add to home screen function and I'm trying to get the title of my web app to display a special character in it but don't know how.
{
"name": "aésmé",
"icons": [
{
"src": "img/icon.png",
"sizes": "192x192",
"type": "image/png",
"density": "4.0"
}
],
"start_url": "index.php",
"display": "standalone",
"orientation": "portrait"
}
推荐答案
我怀疑这是一个字符集问题。确保文件保存时使用的编码与服务器报告的编码匹配。如果您使用的是Apache并且已经以UTF-8格式保存文件(强烈推荐),那么将以下内容添加到.htaccess文件(或者如果您可以访问服务器配置文件):
I suspect that this is a charset issue. Make sure that the encoding with which the file is saved matches the encoding reported by the server when the file is served up. If you're using Apache and you've saved the file in UTF-8 (highly recommended), then add the following to your .htaccess file (or to the server config file, if that's accessible to you):
AddType 'application/json; charset=UTF-8' .json
这也不会伤害到:
AddDefaultCharset utf-8
Note that in theory (according to the application/json
spec), you must use some sort of Unicode encoding for your file (UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE)). Make sure you have saved the file in one of those encodings. Also, the default character set (what the browser uses when no charset is specified) is UTF-8. However, browsers vary quite a bit from this.
这篇关于json文件中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!