From b85f0cbc2f7b412862f9f84faab4815a534dcc2f Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 11 Dec 2018 21:19:09 -0800 Subject: [PATCH] Properly convert command-line arguments to UTF-8 on Windows. Do the same thing we do for most other command-line programs - on Windows, have wmain() rather than main(), convert the UTF-16 argument lists to UTF-8, and pass them on to real_main(), otherwise just have main() call real_main(). That way, they never pass through the local code page on Windows. Change-Id: Ib74176dd0586c012eabaa3376c1d7dcba8838978 Reviewed-on: https://code.wireshark.org/review/31014 Petri-Dish: Guy Harris Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- reordercap.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/reordercap.c b/reordercap.c index 93e2d1bb8d..56d4ae5e33 100644 --- a/reordercap.c +++ b/reordercap.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -160,8 +161,8 @@ failure_message_cont(const char *msg_format, va_list ap) /********************************************************************/ /* Main function. */ /********************************************************************/ -int -main(int argc, char *argv[]) +static int +real_main(int argc, char *argv[]) { GString *comp_info_str; GString *runtime_info_str; @@ -379,6 +380,23 @@ clean_exit: return ret; } +#ifdef _WIN32 +int +wmain(int argc, wchar_t *wc_argv[]) +{ + char **argv; + + argv = arg_list_utf_16to8(argc, wc_argv); + return real_main(argc, argv); +} +#else +int +main(int argc, char *argv[]) +{ + return real_main(argc, argv); +} +#endif + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * -- 2.34.1