[illumos-Discuss] strange error

Garrett D'Amore garrett at damore.org
Sun Jun 26 13:55:56 PDT 2011


Is the locale in question actually installed?

  pkg install pkg:/locale/en

Try it.

Apostolos Syropoulos <asyropoulos at yahoo.com> wrote:

>
>
> Hello,
>
> Today someone posted a message to the gcc-help mailing list. He complained
>because he could not use Unicode characters in a C++ program. He posted a
>program and some list members suggested a modification. The modified program
>follows:
>
>#include <iostream>
>#include <fstream>
>#include <string>
>using namespace std;
>int main() {
>  wstring ws2 = L"Euro:\x20ac";
>  wofstream out("unicode.txt");
>  out.imbue(locale("el_GR.UTF-8"));
>  out << ws2<< endl;
>}
>
>I have no idea what platform he uses but I get the following error
>message when running the g++ generated binary:
>
>terminate called after throwing an instance of 'std::runtime_error'
>  what():  locale::facet::_S_create_c_locale name not valid
>Abort (core dumped)
>
>But when I compile with solstudio the program terminates normally
>but file unicode.txt is empty (i.e., its size is zero). On Linux
>this program runs just fine and creates a file that contains the
>Euro character. According to another poster to gcc-helo, on MacOS
>people get exactly the same error. I guess something is wrong, but
>I have no idea what's wrong. BTW, I have tried to use en_US.UTF-8
>instead of el_GR.UTF-8 but this did not make any difference.
>
>A.S.
>
>
>----------------------
>Apostolos Syropoulos
>Xanthi, Greece
>
>_______________________________________________
>Discuss mailing list
>Discuss at lists.illumos.org
>http://lists.illumos.org/m/listinfo/discuss


More information about the Discuss mailing list