代码之家  ›  专栏  ›  技术社区  ›  Kenny Wyland

如何在PHP中检测宏编码?

  •  1
  • Kenny Wyland  · 技术社区  · 8 年前

    mb_detect_encoding() 不明白 MacRoman

    这就是我要做的:

    $encoding_detection_order = array('UTF-8', 'UTF-7', 'ASCII', 'ISO-8859-1', 'EUC-JP', 'SJIS', 'eucJP-win', 'SJIS-win', 'JIS', 'ISO-2022-JP', );
    
    $encoding = mb_detect_encoding($value, $detection_order, true);
    
    $converted_value = iconv($encoding, 'UTF-8//TRANSLIT', $value);
    

    麦克罗曼 编码时,则上述代码通常会错误地将文本检测为 ISO-8859-1 iconv() 产生不好的结果。

    例如,在 Jaimé 0x8e 在里面 麦克罗曼 ISO-8859-1标准 0x8e 角色是 Ž 所以当我把它转换成utf8,我就得到了utf8版本的 我什么时候该回家 é .

    enter image description here

    麦克罗曼 从其他编码,以便我转换它正确。

    0 回复  |  直到 8 年前
    推荐文章