UTF8真实解码
可能是一个非常简单的问题,但我想知道如何将 utf8 字符解码为可读字符。
例如:
L'heure suprême
进入
L'heure suprême
我尝试了以下操作:
utf8_encode , utf8_decode And `html_entity_decode($string, ENT_COMPAT, "UTF-8");`
输出从未给我正确的字符,例如
html_entity_decode($string, ENT_COMPAT, "UTF-8"); returned L'heure suprême
编辑: 这是一个愚蠢的问题, html_entity_decode($string, ENT_COMPAT, "ISO-8859-15");
成功了
Possibly a very simple question , but I was wondering how I can decode utf8 characters into readable characters.
For example :
L'heure suprême
Into
L'heure suprême
I tried the following :
utf8_encode , utf8_decode And `html_entity_decode($string, ENT_COMPAT, "UTF-8");`
The output never gave me the correct characters , for example
html_entity_decode($string, ENT_COMPAT, "UTF-8"); returned L'heure suprême
EDIT :
It was a stupid question , html_entity_decode($string, ENT_COMPAT, "ISO-8859-15");
did the trick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了正确显示结果,您需要告诉接收端使用哪种编码:
未显式命名字符集编码的输出会引发未定义的行为。今天早些时候,有人推荐了 Joel Spolsky 撰写的一篇关于 Unicode 和字符集的精彩文章。它值得一读,我建议您“略读”它。
In order for your results to be properly displayed, you'll need to tell the receiving end, which encoding is used:
The output without explicitly naming a charset encoding provokes undefined behavior. Earlier today, someone suggested a great article by Joel Spolsky on Unicode and Character sets. It makes for a good read and I'll suggest you "skim over" it.