PHP not have a function for XML-safe entity decode? Not have some xml_entity_decode?

后端 未结 6 1914
旧时难觅i
旧时难觅i 2020-12-17 02:20

THE PROBLEM: I need a XML file \"full encoded\" by UTF8; that is, with no entity representing symbols, all symbols enconded by UTF8, except the only 3 ones that are

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-17 02:46

    For those coming here because your numeric entity in the range 128 to 159 remains as numeric entity instead of being converted to a character:

    echo xml_entity_decode('€');
    //Output € instead expected €
    

    This depends on PHP version (at least for PHP >=5.6 the entity remains) and on the affected characters. The reason is that the characters 128 to 159 are not printable characters in UTF-8. This can happen if the data to be converted mix up windows-1252 content (where € is the € sign).

提交回复
热议问题