mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
MDEV-339, LP1001340 - system_time_zone is wrong on Windows
On localized Windows versions, Windows uses localized time zone names and contain non-ASCII characters. non-ASCII characters appear broken when displayed by clients The fix is to declare system_time_zone variable to have UTF8 encoding and to convert tzname to UTF8.
This commit is contained in:
parent
b14d3adad9
commit
99edca97f4
2 changed files with 17 additions and 8 deletions
|
@ -3418,14 +3418,23 @@ static int init_common_variables()
|
|||
return 1;
|
||||
|
||||
#ifdef HAVE_TZNAME
|
||||
{
|
||||
struct tm tm_tmp;
|
||||
localtime_r(&server_start_time,&tm_tmp);
|
||||
strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
|
||||
sizeof(system_time_zone)-1);
|
||||
struct tm tm_tmp;
|
||||
localtime_r(&server_start_time,&tm_tmp);
|
||||
const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
Time zone name may be localized and contain non-ASCII characters,
|
||||
Convert from ANSI encoding to UTF8.
|
||||
*/
|
||||
wchar_t wtz_name[sizeof(system_time_zone)];
|
||||
mbstowcs(wtz_name, tz_name, sizeof(system_time_zone)-1);
|
||||
WideCharToMultiByte(CP_UTF8,0, wtz_name, -1, system_time_zone,
|
||||
sizeof(system_time_zone) - 1, NULL, NULL);
|
||||
#else
|
||||
strmake(system_time_zone, tz_name, sizeof(system_time_zone)-1);
|
||||
#endif /* _WIN32 */
|
||||
#endif /* HAVE_TZNAME */
|
||||
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
We set SYSTEM time zone as reasonable default and
|
||||
also for failure of my_tz_init() and bootstrap mode.
|
||||
|
|
|
@ -2246,7 +2246,7 @@ static char *system_time_zone_ptr;
|
|||
static Sys_var_charptr Sys_system_time_zone(
|
||||
"system_time_zone", "The server system time zone",
|
||||
READ_ONLY GLOBAL_VAR(system_time_zone_ptr), NO_CMD_LINE,
|
||||
IN_FS_CHARSET, DEFAULT(system_time_zone));
|
||||
IN_SYSTEM_CHARSET, DEFAULT(system_time_zone));
|
||||
|
||||
static Sys_var_ulong Sys_table_def_size(
|
||||
"table_definition_cache",
|
||||
|
|
Loading…
Add table
Reference in a new issue