|
Message-ID: <20160602150154.GJ10893@brightrain.aerifal.cx> Date: Thu, 2 Jun 2016 11:01:54 -0400 From: Rich Felker <dalias@...c.org> To: Remko Tronçon <remko@...tramo.be> Cc: musl@...ts.openwall.com Subject: Re: How to set UTF-8 as default On Thu, Jun 02, 2016 at 01:05:40PM +0200, Remko Tronçon wrote: > Hi, > > When I call `nl_langinfo`, it returns "ASCII" by default. I can call > `setlocale(LC_CTYPE, "C.UTF-8")` to make it return "UTF-8", but I was > wondering if there was a way through environment variables to make C.UTF-8 > be the default. Just call setlocale(LC_CTYPE, ""). This is the only way a correct program should ever use setlocale. Specifying the locale name yourself is not portable and generally contrary to the user's intent and expectations. Passing "" requests the "default" locale, which is implementation-defined by C. POSIX defines it in terms of the LC_* and LANG environment variables if they are set, and an implementation-defined default otherwise. musl's implementation-defined default is C.UTF-8, so everythin works fine even if no env vars are set. > I tried setting LC_CTYPE and LC_ALL to C.UTF-8, but this doesn't seem to > get picked up by `nl_langinfo` (or by `setlocale(LC_CTYPE, NULL)`). NULL is not the same thing as "". Passing NULL as the second argument to setlocale simply queries the current locale name. It does not setup the locale. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.