【发布时间】:2013-06-10 10:10:31
【问题描述】:
以下代码在 Chrome 中发布“it’s”,但在 Safari 中发布“it’s”。
invocation = new XMLHttpRequest()
invocation.open('POST', 'https://example.herokuapp.com/content/24/nl/123')
invocation.setRequestHeader('Content-Type', 'text/plain; charset=UTF-8');
invocation.send('{"data":"it’s"}')
如何说服 Chrome 使用 UTF-8 发布?
【问题讨论】:
-
源文件是utf-8编码的吗?
-
网站标题中有
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">。 -
我通过使用解决方法解决了这个问题:
invocation.send('{"data":encodeURIComponent("it’s")}')
标签: javascript google-chrome encoding