PHP UTF-8 转 Windows 命令行编码 [英] PHP UTF-8 to Windows command line encoding

查看:19
本文介绍了PHP UTF-8 转 Windows 命令行编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一切都在问题中:我有一个 UTF-8 文件的 PHP 脚本.在这个脚本中,我想这样做:

Everything is in the question : I have a Php script that is a UTF-8 file. In this script I want to do this :

  <?
  echo "âêïû
";
  ?>

如果我在 Windows 提示符下运行它,我会得到这个:

If I run it in a Windows prompt I get this :

C:php>php -c C:WINDOWSphp.ini -f mysqldump.php
âêïû
C:php>

我一直无法找到正确的转换方案.我也试过这个代码:

I've not been able to find the right conversion scheme. I've tried also this code :

$tab = mb_list_encodings();
foreach ($tab as $enc1) {
  foreach ($tab as $enc2) {
    $t=mb_convert_encoding("âêïû
", $enc1, $enc2);
    if (strlen($t)<14) {
      echo $enc1." ".$enc2." = ".$t."
";
    }
  }
}

我没有找到正确的转换!

And I didn't find the right conversion !

任何帮助将不胜感激

推荐答案

你让我走上了正轨,但出现了一些问题(我喜欢 Windows o/):

You put me on the right track but there was kinddof a problem (I love Windows o/) :

C:php>chcp 65001
Page de codes active : 65001
C:php>php -c C:WINDOWSphp.ini -f mysqldump.php | more
Mémoire insuffisante.

Mémoire insuffisante = 内存不足.

Mémoire insuffisante = not enough memory.

如果我尝试

C:php>chcp 1252
C:php>php -c C:WINDOWSphp.ini -f mysqldump.php
C:php>ééîîïïÂÂÂÂâûü

它有效.只有上帝知道为什么.但它有效.谢谢你让我走上正轨!!

it works. Only God knows why. But it works. Thanks for putting me on the right track !!

顺便说一句,php代码正确地形成UTF8到命令提示符是:

By the way the php code to go properly form UTF8 to command prompt is :

  echo mb_convert_encoding($utf8_string, "pass", "auto");

这篇关于PHP UTF-8 转 Windows 命令行编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆