Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 30 Nov 2020 12:35:08 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: Dong Brett <brett.browning.dong@...il.com>
Cc: musl@...ts.openwall.com
Subject: Re: Question on C++ locale

* Dong Brett <brett.browning.dong@...il.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

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.