Win32: convert filenames coming in from command line parameters from locale (current code page) into utf8 encoding

This must also be done for the other command line tools like tethereal, editcap and alike ...

svn path=/trunk/; revision=17025
This commit is contained in:
Ulf Lamping 2006-01-12 22:38:37 +00:00
parent a9f4ae4f99
commit 545110c939
2 changed files with 15 additions and 0 deletions

View File

@ -412,7 +412,12 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg,
capture_opts->real_time_mode = TRUE;
break;
case 'w': /* Write to capture file xxx */
#if defined _WIN32 && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
/* since GLib 2.6, we need to convert filenames to utf8 for Win32 */
capture_opts->save_file = g_locale_to_utf8(optarg, -1, NULL, NULL, NULL);
#else
capture_opts->save_file = g_strdup(optarg);
#endif
capture_opts->output_to_pipe = capture_opts_output_to_pipe(capture_opts->save_file);
break;
case 'y': /* Set the pcap data link type */

View File

@ -2284,7 +2284,12 @@ main(int argc, char *argv[])
/* We may set "last_open_dir" to "cf_name", and if we change
"last_open_dir" later, we free the old value, so we have to
set "cf_name" to something that's been allocated. */
#if defined _WIN32 && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
/* since GLib 2.6, we need to convert filenames to utf8 for Win32 */
cf_name = g_locale_to_utf8(optarg, -1, NULL, NULL, NULL);
#else
cf_name = g_strdup(optarg);
#endif
break;
case 'R': /* Read file filter */
rfilter = optarg;
@ -2345,7 +2350,12 @@ main(int argc, char *argv[])
* file - yes, you could have "-r" as the last part of the command,
* but that's a bit ugly.
*/
#if defined _WIN32 && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
/* since GLib 2.6, we need to convert filenames to utf8 for Win32 */
cf_name = g_locale_to_utf8(argv[0], -1, NULL, NULL, NULL);
#else
cf_name = g_strdup(argv[0]);
#endif
}
argc--;
argv++;