]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
asterisk.c: Use C.UTF-8 locale instead of relying on user's environment.
authorSean Bright <sean@seanbright.com>
Fri, 23 Jan 2026 15:57:19 +0000 (10:57 -0500)
committerSean Bright <sean@seanbright.com>
Mon, 26 Jan 2026 19:42:17 +0000 (19:42 +0000)
Resolves: #1739

main/asterisk.c

index 8700a8f7ac331d57bfad56c6c4e6b7816976d1d5..20421eb268206d870efe4baf24fab7d95cbf1a27 100644 (file)
@@ -3629,10 +3629,13 @@ int main(int argc, char *argv[])
        struct rlimit l;
        static const char *getopt_settings = "BC:cde:FfG:ghIiL:M:mnpqRrs:TtU:VvWXx:";
 
-       /* Bring in locale settings from the environment. This is needed
-          for libedit, as the LC_CTYPE category of the locale impacts the
-          the multi-byte character functions provided by libc */
-       setlocale(LC_ALL, "");
+       /* Try to explicitly set a UTF-8 locale. This is needed for
+          libedit, as the LC_CTYPE category of the locale impacts the the
+          multi-byte character functions provided by libc. If it fails,
+          so be it. */
+       if (!setlocale(LC_ALL, "C.UTF-8")) {
+               ast_debug(1, "Tried to set locale to C.UTF-8 but it failed\n");
+       }
 
        /* Remember original args for restart */
        if (argc > ARRAY_LEN(_argv) - 1) {