2

I have a simple script that executes something like:

exec("x.bat", $array);

x.bat returns some special Latin characters, like áéí`'ñ, etc. They are completely garbled in the output array. I've tried setting both the page charset to Windows-1252 and sending "chcp 850" to the cmd before x.bat, but no matter, it always comes out garbled.

Any ideas?

1 Answer 1

3

this solved me the issue once also with special characters

exec("x.bat > result.txt 2>&1");
$data = file_get_contents("result.txt");

+make sure you are adding at the beginning of your php code, the header charset:

header('Content-Type: text/html; charset=Windows-1252');
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I got around to doing just that after a lot of fiddling; Shame there's no easier way, but it worked fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.