aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-12-05 16:00:46 -0800
committerRob Landley <rob@landley.net>2019-12-06 12:44:15 -0600
commit8c6a4db5558f55f176685de8e9ee082f8f7e9ced (patch)
treec65a5cd4f19d5122a64cd203cbd8f27f18d9d8f9
parent31319d35e6c5134a84bfea7d5d3b9c89339da0b6 (diff)
downloadtoybox-8c6a4db5558f55f176685de8e9ee082f8f7e9ced.tar.gz
main.c: fall back to user's locale.
We still prefer C.UTF-8 for predictability, but macOS doesn't have that.
-rw-r--r--main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/main.c b/main.c
index e13b5c29..99c53f96 100644
--- a/main.c
+++ b/main.c
@@ -83,7 +83,11 @@ static void toy_singleinit(struct toy_list *which, char *argv[])
toys.which = which;
toys.argv = argv;
- if (CFG_TOYBOX_I18N) setlocale(LC_CTYPE, "C.UTF-8");
+ if (CFG_TOYBOX_I18N) {
+ // Deliberately try C.UTF-8 before the user's locale to work around users
+ // that choose non-UTF-8 locales. macOS doesn't support C.UTF-8 though.
+ if (!setlocale(LC_CTYPE, "C.UTF-8")) setlocale(LC_CTYPE, "");
+ }
setlinebuf(stdout);
// Parse --help and --version for (almost) all commands