PHP Parsing Problem - amp;nbsp; and #194;(PHP 解析问题 - amp;nbsp;和 )
问题描述
当我尝试解析一些带有 的 html 然后
echo
它时,
变成"这个字符: Â.此外,html_entity_decode()
和 str_replace()
不会改变它.
When I try to parse some html that has
sprinkled through it and then echo
it, the
"turns into" this character: Â. Also, html_entity_decode()
and str_replace()
doesn't change it.
为什么会这样?如何删除 Â 的?
Why is this happening? How can I remove the Â's?
推荐答案
不间断空格存在于两个字节的UTF-8中:<代码>0xC2 和 0xA0
.
The non-breaking space exist in UTF-8 of two bytes: 0xC2
and 0xA0
.
当这些字节在 ISO-8859-1 中表示时(单字节编码)而不是 UTF-8(多字节编码),那么这些字节分别成为字符 Â
和另一个不间断空格 .
When those bytes are represented in ISO-8859-1 (a single-byte encoding) instead of UTF-8 (a multi-byte encoding) then those bytes becomes respectively the characters Â
and another non-breaking space .
显然您正在使用 UTF-8 解析 HTML 并使用 ISO-8859-1 回显结果.要解决此问题,您需要要么使用 ISO-8859-1 解析 HTML,或 使用 UTF-8 回显结果.我建议一直使用 UTF-8.浏览 PHP UTF-8 备忘单 以将其全部对齐.
Apparently you're parsing the HTML using UTF-8 and echoing the results using ISO-8859-1. To fix this problem, you need to either parse HTML using ISO-8859-1 or echo the results using UTF-8. I'd recommend to use UTF-8 all the way. Go through the PHP UTF-8 cheatsheet to align it all out.
这篇关于PHP 解析问题 - &nbsp;和 Â的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP 解析问题 - &nbsp;和 Â


基础教程推荐
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01