From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1373 invoked from network); 30 Nov 2020 14:39:40 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 30 Nov 2020 14:39:40 -0000 Received: (qmail 6139 invoked by uid 550); 30 Nov 2020 14:39:36 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 6118 invoked from network); 30 Nov 2020 14:39:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=O ENhHn6FUCW3mVJt5CDDMbY8Fvdq0nNeo7V0/kepsbw=; b=RDQL/iH3kAsUUKCYt nzwv7y9QdlZ0SwiwS9EGrSEIBKedsHIQ/mDhaz7WVeDhoX1m4tLcw34PJBlOSnnI a7o5fZF7C71IzbqTNNleycdo0StYG1q7C2M2S6D6c9zfUQ3LFVfZQJ79Xnl7k9EM 8oHAwcNc2jot8m9o6E0e1qgmQw4oYHwzpZzuAJ/MKt/SyL8Tmvp0JNL6gahTG13P dwEPWnP0GkD53CK3nLEk9jO0G08h++FaYty9IZaG+AX5cPyxnumJ6WXKNhBvTgH7 Co8W6gLKJQii1/4+26XMBFmrX9EyoWn+yhwnVfC4YIPw5hJ7YnTJ90pv7tdAmZgK iE95Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=OENhHn6FUCW3mVJt5CDDMbY8Fvdq0nNeo7V0/keps bw=; b=krTmyyn8Q6fwDN3xWNeVyLOkt3hwJIz0zWjydgjfTYwK8IbjITW3Uv9Fy w+dQGSAzN7sG7i7xt7C0fKOpw2D7MXEj8GQ8NnZdStxG2et1TfHTLwDESEP4GxbY ynvvvsLPdFagHM+p4KT3j4syko0znwp/ajTCQT5vVjqi5TqmOoNoGzEUbc0hmaWt wr2rToW8tnI4anc+E6rsouHssW8xkZkncNuzNb2ugnDn8AKrMdqb48kSyHG+H74M 6hCmb4m5qyPouV1TviPGdYdZ+fFOhW8enG4BcYNBKUhXE0YicnhZdrj36W8jiw6x HMOSJQ+Hj18vkMqwBUbpdWUJLnNjw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudeitddgieeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepgffhtdfhheejvdeigeehueetteeuhfdvhfelueevkeejleelffdv hfeujeduleetnecuffhomhgrihhnpegtphhluhhsphhluhhsrdgtohhmpdhgnhhurdhorh hgpdhgihhthhhusgdrtghomhdpfhhogihkihhtrdhushenucfkphepjedtrddufeehrddu geekrdduhedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: To: musl@lists.openwall.com, =?UTF-8?Q?=c3=89rico_Nogueira?= , Dong Brett References: From: Samuel Holland Message-ID: <551d3310-039f-23c4-608e-5e15e625f638@sholland.org> Date: Mon, 30 Nov 2020 08:39:18 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [musl] Question on C++ locale On 11/30/20 7:44 AM, Érico Nogueira wrote: > On Mon Nov 30, 2020 at 8:35 AM -03, Szabolcs Nagy wrote: >> * Dong Brett [2020-11-30 18:41:33 >> +0800]: >>> However, the following C++ code does not work (our software uses std::locale in C++ standard library for locale related stuff): >>> #include >>> #include >>> #include >>> using namespace std; >>> int main() >>> { >>> std::locale::global(locale("")); >>> initscr(); >>> printw("LC_ALL: %s\n", setlocale(LC_ALL, NULL)); >>> printw("C++ locale: %s\n", locale().name().c_str()); >>> printw("CODESET: %s\n", nl_langinfo(CODESET)); >>> printw("Hello, world!\n"); >>> printw("你好,世界!\n"); >>> refresh(); >>> getch(); >>> endwin(); >>> return 0; >>> } >> >> fwiw for me even the first line fails. >> i don't know how c++ locales are supposed to work. > > From [1], it seems that C++ locales are supposed to affect the global > locale as well, so they should call setlocale() when appropriate. > > - [1] https://www.cplusplus.com/reference/locale/locale/ > > Unfortunately, I assume libstdc++ uses their generic locale support on > musl... From gcc-10.2.0/libstdc++-v3/config/locale/generic/c_locale.cc: > > void > locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s, > __c_locale) > { > // Currently, the generic model only supports the "C" locale. > // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html > __cloc = 0; > if (strcmp(__s, "C")) > __throw_runtime_error(__N("locale::facet::_S_create_c_locale " > "name not valid")); > } > I don't know for sure that it's the right thing to do, but I have been patching out that error for the last several years[1] and so far I have not noticed any negative effects. Adelie, which is very thorough about testing, has also carried the patch for a while[2]. Samuel [1]: https://github.com/smaeul/portage/blob/c744774a/patches/sys-devel/gcc/gcc-5.4.0-locale.patch [2]: https://code.foxkit.us/adelie/packages/-/commit/d09b437d