summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2025-09-04 20:46:02 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2025-09-05 12:16:07 +0900
commit334d49376dd1afca7427d5e2070d5cc9e270361a (patch)
tree4fbd1797202e06a27ecefccd9130bce86c664bd4
parent83bc6ced920c51ffc3783b03f2e1c7f89f5c2fd5 (diff)
mac: Fallback empty codeset to UTF-8
Workaround for a very strange behavior in macOS (reported about 10.15 at least): `nl_langinfo(CODESET)` returns an empty string until the parent shell sets `LC_CTYPE` (even if it doesn't export it).
-rw-r--r--localeinit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/localeinit.c b/localeinit.c
index cea2e309f5..ed0cc6e433 100644
--- a/localeinit.c
+++ b/localeinit.c
@@ -55,6 +55,9 @@ locale_charmap(VALUE (*conv)(const char *))
#elif defined HAVE_LANGINFO_H
codeset = nl_langinfo(CODESET);
ASSUME(codeset);
+# ifdef __APPLE__
+ if (!*codeset) codeset = "UTF-8";
+# endif
#else
# error locale_charmap() is not implemented
#endif