【问题标题】:PHP & KML file: how to decode utf8 encoded name in KML file?PHP & KML 文件:如何解码 KML 文件中的 utf8 编码名称?
【发布时间】:2012-09-09 07:56:04
【问题描述】:

我必须在 PHP 中解析 KML 文件。 KML 文件中的地标名称采用 UTF8 编码,如下所示:

<name>xD0<U+1ED3>ng ThxE1p</name>

应该是“Đồng Tháp”。如何在 PHP 中正确解析它?谢谢你的提示。

【问题讨论】:

    标签: php utf-8 kml decode


    【解决方案1】:

    正如我所见,编码适用于 utf-16。不是 utf8 http://www.fileformat.info/info/unicode/char/1ed3/index.htm

    【讨论】:

    • 感谢您的快速回复。是的,那是 UTF-16。我试过 mp_convert_encoding($name,'utf-8','auto') 但没有帮助。也许必须先将 XML 编码的字符串转换为原始的 utf-16 字符串,然后接下来...请帮助我。谢谢!
    • 函数 kmlname2html($str){ $str = preg_replace('/x([0-9A-F]+)/','${1};',$str) ; $str = preg_replace('//','${1};',$str);返回 $str; }
    • 我在 html 实体编码中正确获取了字符串。我怎样才能获得 utf8 表示,以便我可以将其用作文件名? mb_convert_encoding($str,'utf-8','auto') 没有帮助。文件名中仍然是 html 实体。有什么帮助吗?
    猜你喜欢
    • 1970-01-01
    • 2012-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多