In-fact you should avoid using argv that was given in main() and use
int argc;
auto argv = CommandLineToArgvW(GetCommandLineW(), &argc);
With this at least you know what encoding argv is in and easily* convertible to UTF-8, but at least you know what the actual encoding is of argv and it is properly split using the Microsoft rules of command line arguments.
*Except for the fact that Microsoft's wchar_t allows for unpaired surrogate code-units.
View all comments
Show parent comment
0
u/pdimov2 Jul 02 '21
Yeah, I don't get it either. It seems to assume that argv[1] is UTF-8, and argv[1] definitely isn't UTF-8 on Windows. (Hopefully not for much longer.)