I need to execute command line commands and tools that accept ut8 as input or generate ut8 output. So I use cmd and it works, but when I try to do it from php with exec, it does not work. To make it simple, I tried a simple output redirection.
When I write directly on the command line:
chcp 65001> nul && echo cschschschuya-öüäß> utf8.txt
The uft8.txt file is created correctly.
tscshshchuya-öüäß
When I use the exec function from php:
$cmd = "chcp 65001 > nul && echo -öüäß>utf8.txt"; exec($cmd,$output,$return); var_dump($cmd,$output,$return);
contents in utf8.txt are mixed up:
¥ Å ¥ Î ¥ ^ ¥% ¥ Z ¥? -ÇôǬÇÏÇY
I am using Win7.64bit with (Console) Codepage 850.
What should I do to fix this?
Additional Information: I am trying to overcome some problems with reading and writing utf8 file names in windows. PHP file functions cannot be executed: glob, scandir, file_exists cannot correctly process utf8 file names. The file is invisible, skipped, names changed ... so I want to avoid php files, and I'm looking for some php extern filehandling.
source share