When I execute from console this command "sendsms XXXXXXXXX 'śćźłóśadad'" everything is OK. But when I execute it in php with exec("sendsms XXXXXXXXX 'śćźłóśadad'"); the body of msg is without polish letters. Debian console is in UTF-8, php file is in UTF-8. When I execute this php file from cli everything is OK but the problem is when I run it from browser (the same file). Why ? How to fix it ?
4
-
1What is "without polish letters"? Do they come out as mojibake, or are they completely ignored?Mr Lister– Mr Lister2013-03-14 09:58:04 +00:00Commented Mar 14, 2013 at 9:58
-
cosśźć => cos (cut the string)mitch– mitch2013-03-14 09:59:24 +00:00Commented Mar 14, 2013 at 9:59
-
but the problem is when I run it from browser - is "cosśźć" user input? if so, sounds like your html page is missing a UTF-8 metatag, and the string your script receives is not what you think.AD7six– AD7six2013-03-14 10:02:31 +00:00Commented Mar 14, 2013 at 10:02
-
No, input is in UTF but I tried run this without input just exec("sendsms 888888888 cosśźćłó");mitch– mitch2013-03-14 10:19:20 +00:00Commented Mar 14, 2013 at 10:19
Add a comment
|
1 Answer
When you run your script via the CLI interface, the subprocess inherits its parent's environment, which contains the variable LANG, used to pass the encoding of the bytes to the underlying C runtime.
Likely when you execute your program via mod_php, LANG is not set. So you may succeed by configuring it yourself:
<?php
putenv('LANG=en_US.UTF-8');
exec("sendsms 888888888 cosśźćłó");