diff options
author | Elliott Hughes <enh@google.com> | 2019-12-05 16:00:46 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-12-06 12:44:15 -0600 |
commit | 8c6a4db5558f55f176685de8e9ee082f8f7e9ced (patch) | |
tree | c65a5cd4f19d5122a64cd203cbd8f27f18d9d8f9 | |
parent | 31319d35e6c5134a84bfea7d5d3b9c89339da0b6 (diff) | |
download | toybox-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 |