我想将字符串的字符编码转换为HTML-ENTITIES,然后再转换为utf-8。我认为转换为某些编码并返回应该给我留下相同的字符串,但它看起来并不像。
我的测试字符串是:
Test: ěščřžýáíé'
转换为HTML-ENTITIES
echo mb_convert_encoding('Test: ěščřžýáíé', 'HTML-ENTITIES', 'UTF-8');
输出此结果:
Test: ěščřžýáíé
然而,当我尝试转换回utf-8
时echo mb_convert_encoding('Test: ěščřžýáíé', 'UTF-8', 'HTML-ENTITIES');
我出乎意料地得到(不正确)输出,而不是原始字符串:
Test: ěščřžýáĂĂ©
如何正确转换编码以获取原始字符串?