Command line character encoding from PHP's exec()

后端 未结 1 1171
执念已碎
执念已碎 2020-12-30 14:04

I\'m trying to pass UTF-8 text as an argument to a command line program using php\'s exec function and have been having problems. I suspect it\'s due to charact

相关标签:
1条回答
  • 2020-12-30 14:43

    Prefix the command with LANG = <language>.UTF8.

    Example:

    $ php -r "echo exec('LANG=\"en_US.UTF8\" locale charmap');"
    UTF-8
    $ php -r "echo exec('LANG=\"en_US.iso88591\" locale charmap');
    ISO-8859-1
    

    You should have the locale installed.

    0 讨论(0)
提交回复
热议问题