diff options
author | Gerald Combs <gerald@wireshark.org> | 2011-05-24 00:07:56 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2011-05-24 00:07:56 +0000 |
commit | a24687ce8eba24d3065bd38c139abfd7720fbb7b (patch) | |
tree | df105f49b2895d2f74db9545ae4235aba0e95562 /wsutil/unicode-utils.c | |
parent | 058fc19f453cc7445a62036a29bc69938ceb1a2a (diff) |
Move the Windows argument list conversion code to a common routine.
svn path=/trunk/; revision=37372
Diffstat (limited to 'wsutil/unicode-utils.c')
-rw-r--r-- | wsutil/unicode-utils.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/wsutil/unicode-utils.c b/wsutil/unicode-utils.c index 80541a5784..567ef180ca 100644 --- a/wsutil/unicode-utils.c +++ b/wsutil/unicode-utils.c @@ -28,6 +28,8 @@ #include "unicode-utils.h" +#include <shellapi.h> + /** @file * Unicode utilities (internal interface) * @@ -141,3 +143,17 @@ utf_16to8(const wchar_t *utf16str) return utf8buf[idx]; } +/* Convert our argument list from UTF-16 to UTF-8. */ +void +arg_list_utf_16to8(int argc, char *argv[]) { + LPWSTR *wc_argv; + int wc_argc, i; + + /* Convert our arg list to UTF-8. */ + wc_argv = CommandLineToArgvW(GetCommandLineW(), &wc_argc); + if (wc_argv && wc_argc == argc) { + for (i = 0; i < argc; i++) { + argv[i] = g_utf16_to_utf8(wc_argv[i], -1, NULL, NULL, NULL); + } + } /* XXX else bail because something is horribly, horribly wrong? */ +} |