From 0e8e119346ea909b8a4acffbe248c485395822ec Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 15 Sep 2023 16:33:20 +0200 Subject: [PATCH] unicode: Fix charset detection on macOS Signed-off-by: Simon Rozman --- include/stdex/unicode.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/stdex/unicode.hpp b/include/stdex/unicode.hpp index 082fcd693..bec5fe1d5 100644 --- a/include/stdex/unicode.hpp +++ b/include/stdex/unicode.hpp @@ -334,7 +334,7 @@ namespace stdex #ifdef _WIN32 return static_cast(GetACP()); #else - const char* lctype = nl_langinfo(LC_CTYPE); + const char* lctype = nl_langinfo(CODESET); if (strcmp(lctype, "UTF-8") == 0) return charset_id::utf8; if (strcmp(lctype, "UTF-16") == 0) return charset_id::utf16; #if BYTE_ORDER == BIG_ENDIAN @@ -386,7 +386,7 @@ namespace stdex "CP1252", // windows1252 }; return - charset == charset_id::system ? nl_langinfo(LC_CTYPE) : + charset == charset_id::system ? nl_langinfo(CODESET) : encodings[static_cast>(charset)]; }