chiark / gitweb /
do not change console to non-unicode for LANG=C
authorHarald Hoyer <harald@redhat.com>
Mon, 15 Apr 2013 16:34:53 +0000 (18:34 +0200)
committerHarald Hoyer <harald@redhat.com>
Mon, 15 Apr 2013 16:37:24 +0000 (18:37 +0200)
If systemd-vconsole-setup was started with LANG=C (no locale.conf), then
it would set the console to non-unicode, which is not what we want.

src/shared/util.c

index 5827f6c7a14dfa3afbebc0e0befd601d5f6ca277..5d6995d23f878eb8d081d1318e2c0bbed5f8d982 100644 (file)
@@ -5402,7 +5402,23 @@ bool is_locale_utf8(void) {
                 goto out;
         }
 
-        cached_answer = streq(set, "UTF-8");
+        if(streq(set, "UTF-8")) {
+                cached_answer = true;
+                goto out;
+        }
+
+        /* For LC_CTYPE=="C" return true,
+         * because CTYPE is effectly unset and
+         * everything defaults to UTF-8 nowadays. */
+
+        set = setlocale(LC_CTYPE, NULL);
+        if (!set) {
+                cached_answer = true;
+                goto out;
+        }
+
+        cached_answer = streq(set, "C");
+
 out:
         return (bool)cached_answer;
 }