问题
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"
}
回答1:
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
It wouldn't hurt to also add:
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.
回答2:
It can be one of two: 1. You are messing up with the utf8 conversion. You either didn't convert, or worse, did it twice tesulting with strange looking characters. 2. If you need to use special characters consider using base64, although it would render the text unreadable in a text editor.
来源:https://stackoverflow.com/questions/30017020/special-characters-in-json-file