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

查看:370
本文介绍了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 "âêïû\n";
  ?>

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

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

C:\php>php -c C:\WINDOWS\php.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("âêïû\n", $enc1, $enc2);
    if (strlen($t)<14) {
      echo $enc1." ".$enc2." = ".$t."\n";
    }
  }
}

正确的转换!

任何帮助将非常感谢。

推荐答案

你把我放在正确的轨道,但有kinddof一个问题(我喜欢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:\WINDOWS\php.ini -f mysqldump.php | more
Mémoire insuffisante.

Mémoireinsuffisante =内存不足。

Mémoire insuffisante = not enough memory.

如果我尝试

C:\php>chcp 1252
C:\php>php -c C:\WINDOWS\php.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天全站免登陆