From: Szabolcs Nagy <nsz@port70.net>
To: Dong Brett <brett.browning.dong@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Question on C++ locale
Date: Mon, 30 Nov 2020 12:35:08 +0100 [thread overview]
Message-ID: <20201130113508.GQ1370092@port70.net> (raw)
In-Reply-To: <62BA8BC9-9943-418A-8349-2B1FB962EDE9@gmail.com>
* Dong Brett <brett.browning.dong@gmail.com> [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 <langinfo.h>
> #include <locale.h>
> #include <locale>
> 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.
$ cat a.cc
#include <locale>
using namespace std;
int main()
{
std::locale::global(locale(""));
return 0;
}
$ g++ a.cc
$ ./a.out
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Aborted
next prev parent reply other threads:[~2020-11-30 11:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-30 10:41 Dong Brett
2020-11-30 11:31 ` Szabolcs Nagy
2020-11-30 11:58 ` Dong Brett
2020-11-30 11:35 ` Szabolcs Nagy [this message]
2020-11-30 12:37 ` Érico Nogueira
2020-11-30 13:44 ` Érico Nogueira
2020-11-30 14:39 ` Samuel Holland
2020-11-30 14:48 ` Rich Felker
2020-11-30 15:12 ` Érico Nogueira
2020-11-30 15:35 ` Rich Felker
2020-11-30 17:14 ` Érico Nogueira
2020-11-30 18:11 ` Rich Felker
2020-11-30 14:51 ` Rich Felker
2020-12-09 14:35 ` Érico Nogueira
2020-12-09 16:41 ` Rich Felker
2020-12-01 3:53 ` [musl] " Dong Brett
2020-12-01 16:21 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201130113508.GQ1370092@port70.net \
--to=nsz@port70.net \
--cc=brett.browning.dong@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).