Use Unicode command line when not using wmain() under Windows
While we use wmain() for the compilers that provide it since the changes of
bfa78c63b9
, we still didn't handle Unicode
command line arguments not representable in the current Windows code page
correctly when using other compilers (e.g. MinGW).
Now use Win32 ::GetCommandLine() function for them and parse the command line
ourselves instead of relying on non-Unicode-friendly main() arguments which
can't represent arbitrary Unicode strings when not using UTF-8 (which is never
the case under Windows).
This commit is contained in:
@@ -798,17 +798,31 @@ public:
|
||||
// your compiler really, really wants main() to be in your main program (e.g.
|
||||
// hello.cpp). Now wxIMPLEMENT_APP should add this code if required.
|
||||
|
||||
// For compilers that support it, prefer to use wmain() as this ensures any
|
||||
// Unicode strings can be passed as command line parameters and not just those
|
||||
// representable in the current locale.
|
||||
#if wxUSE_UNICODE && defined(__VISUALC__)
|
||||
#define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \
|
||||
int wmain(int argc, wchar_t **argv) \
|
||||
{ \
|
||||
wxDISABLE_DEBUG_SUPPORT(); \
|
||||
// For compilers that support it, prefer to use wmain() and let the CRT parse
|
||||
// the command line for us, for the others parse it ourselves under Windows to
|
||||
// ensure that wxWidgets console applications accept arbitrary Unicode strings
|
||||
// as command line parameters and not just those representable in the current
|
||||
// locale (under Unix UTF-8, capable of representing any Unicode string, is
|
||||
// almost always used and there is no way to retrieve the Unicode command line
|
||||
// anyhow).
|
||||
#if wxUSE_UNICODE && defined(__WINDOWS__)
|
||||
#ifdef __VISUALC__
|
||||
#define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \
|
||||
int wmain(int argc, wchar_t **argv) \
|
||||
{ \
|
||||
wxDISABLE_DEBUG_SUPPORT(); \
|
||||
\
|
||||
return wxEntry(argc, argv); \
|
||||
}
|
||||
return wxEntry(argc, argv); \
|
||||
}
|
||||
#else // No wmain(), use main() but don't trust its arguments.
|
||||
#define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \
|
||||
int main(int, char **) \
|
||||
{ \
|
||||
wxDISABLE_DEBUG_SUPPORT(); \
|
||||
\
|
||||
return wxEntry(); \
|
||||
}
|
||||
#endif
|
||||
#else // Use standard main()
|
||||
#define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \
|
||||
int main(int argc, char **argv) \
|
||||
|
Reference in New Issue
Block a user