我有一个包含印度语/印地语文本的文本文件我做了一个简单的php代码,使用shell_exec()在字符串/流中获取wc命令的输出。我的wc.php代码如下::
<?php
$filename = '/tmp/1371272031.txt';
//above file contains hindi text
$cmd = 'wc ' . $filename;
$wcoutput = shell_exec($cmd);
echo $wcoutput;
?>
文件'/tmp/1371272031.txt '包含印地语文本。
当我从终端运行这段代码时使用命令
php wc.php
然后我得到输出像在终端运行wc命令"wc/tmp/1371272031.txt"
输出为::
5 9 74 /tmp/1371272031.txt
但是当我从浏览器像http://dashboard2.iiit.ac.in/abc/wc.php运行这段代码它给出如下输出
5 0 74 /tmp/1371272031.txt
在浏览器中给出不同的输出。
在执行shell_exec()
之前,尝试在php脚本中设置区域设置。像这样。
putenv("LANG=C.UTF-8");