[systemd-devel] [PATCH 2/2] util.c:is_locale_utf8(): check, if "C" was set on purpose

harald at redhat.com harald at redhat.com
Thu Jun 27 02:26:36 PDT 2013


From: Harald Hoyer <harald at redhat.com>

If you have a ASCII only terminal, there is no way to set the charmap to
ANSI_X3.4-1968, other than using LC_CTYPE=C.

We don't want to assume a UTF-8 capable terminal in this case and only
do so, if LANG, LC_ALL and LC_CTYPE are unset.
---
 src/shared/util.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/shared/util.c b/src/shared/util.c
index 04811ff..c4b644b 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5387,6 +5387,10 @@ bool is_locale_utf8(void) {
 
         cached_answer = streq(set, "C");
 
+        /* LC_CTYPE=="C", now check, if it was set by purpose */
+        if (cached_answer && (getenv("LC_ALL") || getenv("LC_CTYPE") || getenv("LANG")))
+                cached_answer = false;
+
 out:
         return (bool)cached_answer;
 }
-- 
1.8.3.1



More information about the systemd-devel mailing list