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,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26532 invoked from network); 30 Nov 2020 13:48:40 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 30 Nov 2020 13:48:40 -0000 Received: (qmail 9833 invoked by uid 550); 30 Nov 2020 13:48:32 -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 9815 invoked from network); 30 Nov 2020 13:48:32 -0000 X-Virus-Scanned: Debian amavisd-new at disroot.org Mime-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1606744097; bh=+iBbef9cOQ2vzYVKXkC/hhsYED8xUculY95WWdMYWUI=; h=Subject:From:To:Date:In-Reply-To; b=J6dbUrCNnYHRe4YNZ1F/Zvo8hJfbx6hn2/FgWwFdCh1iQAUL5ZimjL2Qt6sKbVPTt N7LFZOxVtICj1hybEpIZShE0GSoZjV1ebhRjA6zM6gLARiy0trdMp2nnlGGe+iqJXf WjIiZUhB5mtcUw93devKTdw+msE0vsidq2pr40pseJ/SQCGR4bdGzkrPzK7R3MXiUs 0kNBRbdiZkX8D95JLexQDGOk5mkfeasiR7IlGZtA6J3o7PBOIoeNcdHnpJFbkzYusk HAwkyGK6wRVwrAruBAXmH8fdmQWxDSD7vpYW+Ki4YhbF3RxAqOSpkBSn1ehG0ez/Zt wUlK4A21OfXuQ== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 From: =?utf-8?q?=C3=89rico_Nogueira?= To: , "Dong Brett" Date: Mon, 30 Nov 2020 10:44:49 -0300 Message-Id: In-Reply-To: <20201130113508.GQ1370092@port70.net> Subject: Re: [musl] Question on C++ locale 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::l= ocale 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("=E4=BD=A0=E5=A5=BD=EF=BC=8C=E4=B8=96=E7=95=8C!\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 =3D 0; if (strcmp(__s, "C")) __throw_runtime_error(__N("locale::facet::_S_create_c_locale " "name not valid")); }