|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-08-19 22:35 UTC] bugzilla77 at gmail dot com
Description: ------------ https://github.com/php/php-src/blob/php-7.1.0beta3/UPGRADING "The recommended way to handle file paths, I/O and other related topics is by utilizing UTF-8." Expected result: ---------------- shell_exec() returns UTF-8 data Actual result: -------------- shell_exec()does not work even in the local system code page. It returns ? instead local letters. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 21:00:02 2026 UTC |
Thanks for the further info. This is not specific to 7.1 changes or shell_exec, however. The content-type header imply, that all of the output is in the given charset. Specific to 7.1 on Windows is, that the default_charset affects how the filenames are handled, but not the output from an external program. Internally, PHP will convert the given filename to/from UTF-16 using the specified default_charset. If default_charset=UTF-8, any possible filenames can be handled. Otherwise, fe default_charset=cp1250 like in this case, some filenames like Asian or Cyrillic, are likely not to be supported correctly. That will OFC also affect, how the filenames are read to PHP, and how they're output (fe in error messages, etc.). PHP already sends the corresponding headers for server SAPIs, and with 7.1 it also switches to the corresponding codepage on CLI. For instance, notice the length returned: php.exe -r "$f = 'żółć'; touch($f); var_dump(pathinfo($f)); unlink($f);" array(3) { ["dirname"]=> string(1) "." ["basename"]=> string(8) "żółć" ["filename"]=> string(8) "żółć" } php.exe -d default_charset=cp1250 -r "$f = 'żółć'; touch($f); var_dump(pathinfo($f)); unlink($f);" array(3) { ["dirname"]=> string(1) "." ["basename"]=> string(4) "żółć" ["filename"]=> string(4) "żółć" } The encoding information is vital for Windows, to do the correct conversion of the filename. But, and it is even not Windows specific, not even 7.1 specific, PHP won't convert an output from some program to the default_charset. The recommendation in the UPGRADING tells exactly that - from 7.1 on the script needs to use a homogeneous encoding across all its parts, specifically filenames. Before 7.1, only Window APIs with ANSI codepage support are used, despite default_charset=utf-8. Thanks.