-->

PHP检测和转换特殊字符?(PHP to detect and convert Special Ch

2019-09-22 06:41发布

在PHP,当我读到的数据,让说的数据(串块)被包含像HTML特殊字符十进制十六进制代码:
This is a sample string with œ and š

我们可以说,上述十六进制代码及其对应符号的源代码,这些将被呈现在浏览器上正确的符号。

但我想要做的是,这些字符(例如),我想这些HEX(ES)作为转换后的原始字符符号,如:
This is a sample string with œ and š

所以,我怎么可以检测到任何十进制十六进制代码的字符串内,他们每个人转化成最终的图形符号 ,而不是保持的十六进制代码?

注意:
欲了解更多clearence,没有任何功能来检测和十六进制转换为符号?
喜欢:
œ => œ
š => š

Answer 1:

$s = "This is a sample string with œ and š";
echo html_entity_decode($s, ENT_COMPAT, 'UTF-8');


Answer 2:

这些都是HTML实体-你可以回到实际的符号与html_entity_decode()



Answer 3:

确保任何使用(数据库表,JSON或XML进行数据交换,html文件等等等等)是UTF-8格式



文章来源: PHP to detect and convert Special Characters?