summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-02-20 15:34:25 +0900
committerNobuyoshi Nakada <[email protected]>2025-02-20 15:34:32 +0900
commit34098b669c0cbc024cd08e686891f1dfe0a10aaf (patch)
treedf59b2b32efbde987f48179ad0f67be9605843fa /time.c
parent556be73cbbf3845c448ca4f546411be18d523f33 (diff)
[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.
Diffstat (limited to 'time.c')
-rw-r--r--time.c6
1 files changed, 6 insertions, 0 deletions
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);
}