[Bug #21144] Win32: Convert the time zone name to the current locale

The Windows time zone IDs provided by Microsoft as of 24H1 are ASCII
only all, but the API itself is not impossible to set non-ASCII key
name.  Prefer the current locale encoding for now until we move to
UTF-8 including environment variables and command line arguments.
This commit is contained in:
Nobuyoshi Nakada 2025-02-20 15:34:25 +09:00
parent 556be73cbb
commit 34098b669c
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465

6
time.c
View File

@ -999,7 +999,13 @@ zone_str(const char *zone)
str = rb_usascii_str_new(zone, len);
}
else {
#ifdef _WIN32
str = rb_utf8_str_new(zone, len);
/* until we move to UTF-8 on Windows completely */
str = rb_str_export_locale(str);
#else
str = rb_enc_str_new(zone, len, rb_locale_encoding());
#endif
}
return rb_fstring(str);
}