diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-12-31 15:32:42 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-12-31 23:33:31 +0000 |
commit | 9a7d4559aed27208b4688cb6d0c9c8a810612788 (patch) | |
tree | 606cae060e4342cb5cd9c399d9f56b2b351d762c /wsutil | |
parent | 1bc2565bff009e0b2560c4c8401da447d00d4668 (diff) |
Use setlocale() to get the current locale.
This:
1) should work on Windows;
2) reflects what the C environment is actually set up to use,
rather than what the environment variables for locale are
set up to use - C programs default to the C locale and only
pick up the setting from the environment variables etc. if
you explicitly request the system locale with a setlocale()
call.
Change-Id: Iee064237e70501a5450d4daa9ab849391f200efd
Reviewed-on: https://code.wireshark.org/review/6195
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/ws_version_info.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/wsutil/ws_version_info.c b/wsutil/ws_version_info.c index baa0a9a3f2..1950ef3cd4 100644 --- a/wsutil/ws_version_info.c +++ b/wsutil/ws_version_info.c @@ -25,6 +25,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <locale.h> #ifdef _WIN32 #include <windows.h> @@ -263,21 +264,32 @@ GString * get_runtime_version_info(void (*additional_info)(GString *)) { GString *str; -#ifndef _WIN32 gchar *lang; -#endif str = g_string_new("Running on "); get_os_version_info(str); -#ifndef _WIN32 - /* Locale */ - if ((lang = getenv ("LANG")) != NULL) + /* + * Locale. + * + * This returns the C language's locale information; this + * returns the locale that's actually in effect, even if + * it doesn't happen to match the settings of any of the + * locale environment variables. + * + * XXX - what happens on Windows? If nobody's explicitly + * overridden any of the environment variables, does this + * reflect the locale settings in the OS? If so, does + * that include the code page? (We're not using UTF-16 + * for output to files or the console; using code page + * 65001, i.e. UTF-8, as your system code page probably + * works best with Wireshark.) + */ + if ((lang = setlocale(LC_ALL, NULL)) != NULL) g_string_append_printf(str, ", with locale %s", lang); else g_string_append(str, ", with default locale"); -#endif /* Additional application-dependent information */ if (additional_info) |