特殊字符显示为?分数 [英] Special characters display as ? marks
问题描述
我有一些特殊字符的位置:
http://209.141.56.244/test/char.php
I have some special characters here:
http://209.141.56.244/test/char.php
但是当我在这里通过AJAX抓住这个文件,它们显示的回来吗?标志:
http://209.141.56.244/test/char.html
but when I grab this file via ajax here, they show up as back ? marks:
http://209.141.56.244/test/char.html
这些角色应该是ISO-8859-1西方但切换浏览器的编码,以任何选项都没有帮助。
These characters should be "ISO-8859-1 Western" but switching my browser encoding to any of the options don't help.
这是为什么,我该如何解决?
Why is this and how can I fix it?
推荐答案
您的服务器发送Ajax响应为的text / html
,这使得浏览器假设UTF-8(这是默认的),但你的数据本身不是UTF-8。
Your server sends the Ajax response as text/html
, this makes the browser assume UTF-8 (which is the default), but your data itself is not UTF-8.
发送Ajax响应为的text / html;字符集=窗口1252
(你没有真正使用ISO-8859-1),它应该工作。
Send the Ajax response as text/html; Charset=Windows-1252
(you're not really using ISO-8859-1) and it should work.
header('Content-Type: text/html; Charset=Windows-1252');
PS:切换浏览器到另一个字符集没有帮助,因为这不仅影响页面本身。随后的Ajax响应还是去codeD根据各自的标题。
PS: Switching the browser to another charset does not help because this affects the page itself only. Subsequent Ajax responses are still decoded according to their respective headers.
这篇关于特殊字符显示为?分数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!