php 和特殊字符
我正在尝试从法语文本中解析字符串,并且我同时使用 htmlspecialchars 和 html_entity_decode - 但某些字符未正确转换。
有什么想法吗?
这是代码:
html_entity_decode(htmlspecialchars_decode($this->string($tstring))); // returned from web service
特别是,未解码的实体是这个:
'
感谢您的帮助!
I'm trying to parse a string from a French text, and I'm using both htmlspecialchars and html_entity_decode-- but certain characters aren't getting properly converted.
Any ideas?
Here's the code:
html_entity_decode(htmlspecialchars_decode($this->string($tstring))); // returned from web service
In particular, the entity that isn't decoding is this one:
'
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要传递
ENT_QUOTES
作为 quote_style 参数:http://php.net/manual/en/function.html-entity-decode.php
否则,
html_entity_decode()
默认为ENT_COMPAT
,它将转换双引号字符,但不接触单引号字符(这就是'
- 单引号)。You need to pass
ENT_QUOTES
as the quote_style parameter:http://php.net/manual/en/function.html-entity-decode.php
Otherwise,
html_entity_decode()
defaults toENT_COMPAT
which converts double-quote characters but doesn't touch single-quote characters (which is what'
is - a single quote).