【问题标题】:convert KOI8-R to UTF8将 KOI8-R 转换为 UTF8
【发布时间】:2010-11-16 21:38:38
【问题描述】:

我需要将 KOI8-R 编码的字符串转换为纯 UTF8

【问题讨论】:

  • 请注意,只有在您 100% 知道原始编码是什么时,才能保证在编码之间进行转换。

标签: php encoding utf-8


【解决方案1】:

你可以使用mb_convert_encoding:

$output = mb_convert_encoding($input, 'UTF-8', 'KOI8-R');

【讨论】:

    【解决方案2】:
    $output = iconv('KOI8-R', 'UTF-8', $input);
    

    也有效:)

    还可以选择删除损坏或无法识别的字符

    iconv("KOI8-R", "UTF-8//IGNORE", $text)
    

    但你需要安装 iconv。

    【讨论】:

      猜你喜欢
      • 2012-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2021-06-21
      相关资源
      最近更新 更多