Conversation
|
cc @alexandre-daubois as this concerns frankenphp cc @shivammathur for windows-specific review I think |
| using_wide_argv = 1; | ||
| /* Embedders supply their own arguments, we mustn't replace them with | ||
| * the ones by the host process command line. */ | ||
| if (argv_save == __argv) { |
There was a problem hiding this comment.
The caller's own argv skips the transcoding to PHP's internal charset that the CommandLineToArgvW() branch performs, so a narrow main() host passing café.php in the ANSI code page hands raw ANSI bytes to the script lookup and to $argv. You may want to document in UPGRADING.INTERNALS that do_php_cli() expects argv in the internal encoding on Windows, or convert from CP_ACP on this branch.
There was a problem hiding this comment.
Hmm, fair point. I'm not aware of a safe detection + conversion in winapi, so it might indeed have to be documented.
|
Hmm, small issue in this is also that we're kind of expecting embedders to pass argv in the internal encoding (which is utf-8 by default, but short of explicitly overwriting it, an embedder couldn't be sure). Should we instead require utf-8 and do the conversion if necessary? It's a bit extra code. Edit: went with always taking utf-8, I don't see another good way of dealing with it. |
https://learn.microsoft.com/en-us/cpp/c-runtime-library/argc-argv-wargv?view=msvc-170
if we get called by an embedder (argv != __argv) don't re-parse the cmd.