From 8c6a4db5558f55f176685de8e9ee082f8f7e9ced Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 5 Dec 2019 16:00:46 -0800 Subject: main.c: fall back to user's locale. We still prefer C.UTF-8 for predictability, but macOS doesn't have that. --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'main.c') 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 -- cgit v1.2.3