1
0
Fork 0

Windows: read Unicode command line

One more step in full Unicode support.
This commit is contained in:
James Turner 2019-04-27 18:50:24 +01:00
parent 9d71d09072
commit bac5d6c713

View file

@ -134,9 +134,22 @@ static void initFPE(bool)
#if defined(SG_WINDOWS)
int main ( int argc, char **argv );
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
LPSTR lpCmdLine, int nCmdShow)
{
// convert wchar_t args to UTF-8 which is what we expect cross-platform
int numArgs = 0;
LPWSTR* wideArgs = CommandLineToArgvW(GetCommandLineW(), &numArgs);
main( __argc, __argv );
std::vector<char*> utf8Args;
utf8Args.reserve(numArgs);
for (int a = 0; a < numArgs; ++a) {
const auto s = simgear::strutils::convertWStringToUtf8(wideArgs[a]);
// note we leak these (strudp calls malloc) but not a big concern
utf8Args[a] = strdup(s.c_str());
}
main(numArgs, utf8Args.data());
}
#endif