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");
相关文章