我有一个包含这些代码的文件,我想将它“翻译”成普通字符(我的意思是整个文件)。我该怎么做?
非常感谢您提前。
看起来您最初有一个 UTF-8 文件,该文件已被解释为 8 位编码(例如ISO-8859-15)和实体编码。我这样说是因为序列 C3A9 看起来像是一个相当合理的 UTF-8 编码序列。
您需要先对其进行实体解码,然后再进行 UTF-8 编码。然后,您可以使用iconv之类的东西转换为您选择的编码。
要完成您的示例:
你提到想用 PHP 处理这个问题,这样的事情可能会为你做:
//to load from a file, use
//$file=file_get_contents("/path/to/filename.txt");
//example below uses a literal string to demonstrate technique...
$file="&Précédent is a French word";
$utf8=html_entity_decode($file);
$iso8859=utf8_decode($utf8);
//$utf8 contains "Précédent is a French word" in UTF-8
//$iso8859 contains "Précédent is a French word" in ISO-8859