【问题标题】:Printing extended ASCII characters in PHP using CP437使用 CP437 在 PHP 中打印扩展的 ASCII 字符
【发布时间】:2019-04-22 05:04:47
【问题描述】:

我需要在 PHP 中使用 CP437(例如“É” = 144)打印扩展的 ASCII 代码。

目前,echo utf8_encode(chr(144)) 只会在我的控制台中显示一个问题框(Windows 上的 Ubuntu 上的 Bash)。

使用for ($i = 0; $i < 255, $i++) echo utf8_encode(chr($i)),我看到“É”实际上是201;我假设这里的代码页是 65001,使用 this ASCII table

如何在 PHP 中使用 CP437 获得 ASCII 字符代码的字符串表示形式?

【问题讨论】:

    标签: php string encoding utf-8 ascii


    【解决方案1】:

    您可以使用iconv 将字符串从一种编码转换为另一种编码。例如,要将 chr(144) 从 cp437 转换为 utf8,您可以:

    echo iconv('cp437', 'utf8', chr(144));
    // output: É
    

    如果您要将 转换为 cp437,请反转参数:

    echo iconv($originalEncoding, 'cp437', $originalString);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-01
      • 2011-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-20
      • 1970-01-01
      相关资源
      最近更新 更多