转换特殊字符CodeHex Php


Convert Special Character to CodeHex Php

我必须将特殊字符转换为CodeHex例如

À => À

我尝试了html_entity_decode, utf8_encode, htmlentities,但是没有成功。

我必须创建一个xml文件

毫无疑问,如果转换是真的需要/有用:你可以先得到ASCII码,然后将其转换为十六进制:

echo "&#x".strtoupper(dechex(ord('À'))).";"

要在浏览器中回显内容,可以使用

echo htmlentities("&#x".strtoupper(dechex(ord("À"))).";");

或者-根据您的编码,尝试使用utf8_decode作为您的输入(在这里测试):

echo htmlentities("&#x".strtoupper(dechex(ord(utf8_decode("À")))).";");

则输出正确显示为À