元数据无法解码 PHP
此链接的元描述:http://www.mercurynews.com/ Samesexmarriage/ci_17794445?source=most_viewed&nclick_check=1
返回一个奇怪的字符而不是引号。
The federal judge who struck down Californias gay marriage ban has confirmed that hes gay. Chief U.
我正在使用 strip_tags(html_entity_decode(htmlspecialchars_decode($description, ENT_NOQUOTES), ENT_NOQUOTES, "UTF-8"));
做什么?这个奇怪的字符出现在“California's”和“He's”一词中的引用位置
The meta description for this link: http://www.mercurynews.com/samesexmarriage/ci_17794445?source=most_viewed&nclick_check=1
Is returning a strange character instead of a quote.
The federal judge who struck down Californias gay marriage ban has confirmed that hes gay. Chief U.
I am using strip_tags(html_entity_decode(htmlspecialchars_decode($description, ENT_NOQUOTES), ENT_NOQUOTES, "UTF-8"));
What do? The weird character appears in place of a quote in the word "California's" and "He's"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该网站对 HTML 实体的编码不正确。源中的那些撇号应编码为
'
— 撇号的十六进制数字实体(十进制数字 39)。他们使用,它是 ASCII“Escape”字符的十进制数字实体。
您可以通过添加
str_replace
调用轻松地弥补他们的错误:ASCII 代码参考
The site is encoding the HTML entities incorrectly. Those apostrophes in the source should be encoded as
'
— the hexadecimal number entity for the apostrophe (decimal number 39). They are using, which is the decimal number entity for the ASCII "Escape" character.
You can cover for their mistake pretty easily by adding a
str_replace
call:Reference for ASCII codes