php 和特殊字符

发布于 2024-09-10 08:43:43 字数 316 浏览 0 评论 0原文

我正在尝试从法语文本中解析字符串,并且我同时使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久夏青 2024-09-17 08:43:43

您需要传递 ENT_QUOTES 作为 quote_style 参数:

http://php.net/manual/en/function.html-entity-decode.php

否则,html_entity_decode() 默认为 ENT_COMPAT ,它将转换双引号字符,但不接触单引号字符(这就是 ' - 单引号)。

$result = html_entity_decode($input_string, ENT_QUOTES);

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 to ENT_COMPAT which converts double-quote characters but doesn't touch single-quote characters (which is what ' is - a single quote).

$result = html_entity_decode($input_string, ENT_QUOTES);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文