From 34098b669c0cbc024cd08e686891f1dfe0a10aaf Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 20 Feb 2025 15:34:25 +0900 Subject: [PATCH] [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. --- time.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/time.c b/time.c index 56f93ec58d..b12e68f69a 100644 --- a/time.c +++ b/time.c @@ -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); }