From: Sean Bright Date: Fri, 23 Jan 2026 15:57:19 +0000 (-0500) Subject: asterisk.c: Use C.UTF-8 locale instead of relying on user's environment. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a27114d45c7cfc5812f0cf74de764c1f1b279d4a;p=thirdparty%2Fasterisk.git asterisk.c: Use C.UTF-8 locale instead of relying on user's environment. Resolves: #1739 --- diff --git a/main/asterisk.c b/main/asterisk.c index 8700a8f7ac..20421eb268 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -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) {