脚本宝典收集整理的这篇文章主要介绍了php exec()在unicode模式下?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在命令提示符下直接写:
创建了uft8.txt,内容是正确的.
$cmd = "chcp 65001 > nul && echo цчшщюя-öüäß>utf8.txt"; exec($cmd,$output,$return); var_dump($cmd,$return);
utf8.txt中的内容搞砸了:
我该怎么做才能解决这个问题?
其他信息:
我试图克服在Windows上读取和写入utf8文件名的一些问题.
PHP文件函数失败:glob,scandir,file_exists无法正确处理utf8文件名.文件不可见,跳过,名称被更改…
因此,我想避免PHP文件功能,我正在寻找一些PHP extern文件处理.
function uft8_exec($cmd,&$output=null,&$return=null) { //get current work directory $cd = getcwd(); // on multilines commands the line should be ended with "\r\n" // otherwise if unicode text is there,parsing errors may occur $cmd = "@echo off @chcp 65001 > nul @cd \"$cd\" ".$cmd; //create a temporary cmd-batch-file //need to be extended with unique generic tempnames $tempfile = 'PHP_exec.bat'; file_put_contents($tempfile,$cmd); //execute the batch exec("start /b ".$tempfile,$return); // get rid of the last two lin of the output: an empty and a prompt array_pop($output); array_pop($output); //if only one line output,return only the extracted value if(count($output) == 1) { $output = $output[0]; } //delete the batch-tempfile unlink($tempfile); return $output; }
要么
以上是脚本宝典为你收集整理的php exec()在unicode模式下?全部内容,希望文章能够帮你解决php exec()在unicode模式下?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。