Non-ASCII command-line arguments are mangled on Windows #11558
Labels
kind:bug
A bug in the code. Does not apply to documentation, specs, etc.
platform:windows
Windows support based on the MSVC toolchain / Win32 API
topic:stdlib:system
topic:stdlib:text
If you try to pass any non-ASCII command-line arguments to a Crystal program built on Windows, they are transcoded to Windows-1252:
This happens even before the entry point is called, regardless of the current console codepage. A solution is to use the wide entry point
wmain
on Windows only, and convert the command-line arguments back to UTF-8 before executing any top-level code:We cannot simply call
GetCommandLineW
/CommandLineToArgvW
and ignoreargc
andargv
inCrystal.main
, because that method might be captured and passed somewhere (apparently this use case is publicly documented). But we may be able to do this infun main
, without the standard library:The text was updated successfully, but these errors were encountered: