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).
This commit is contained in:
Nobuyoshi Nakada committed 2025-09-05 12:16:07 +09:00
1 parent 83bc6ced92
commit 334d49376d
1 file changed
+3
+3
View File
@@ -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