Re: output unicode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27 June 2011 17:35, eric wrote:
> On Mon, 2011-06-27 at 17:03 +0100, Jonathan Wakely wrote:
>> On 27 June 2011 16:39, eric <fsshl@xxxxxxx> wrote:
>> > Dear advanced c/g++ programers:
>> >  after I copied and compiled last email's code
>> >  I tested it, with your suggestion (put POSIX and C behind it), they
>> > run (generate locale),
>> > but
>> > all test failed to make output file with size > 0
>> > so if you can plz help again, and thank a lot in advance, Eric
>> >
>> > ------------------------------------------------------------
>> > eric@eric-laptop:~/cppcookbook$ ./a.out
>> > trying to access locale el_GR.utf8
>> > Couldn't generate locale el_GR.utf8: locale::facet::_S_create_c_locale
>> > name not valid
>> > Error when writing to file
>>
>> As shown by 'locale -a' you don't have the el_GR.utf8 locale
>> installed, so obviously this won't work.
>>
>> > eric@eric-laptop:~/cppcookbook$ ls -l -a unicode.txt
>> > -rw-r--r-- 1 eric eric 0 2011-06-27 08:31 unicode.txt
>> > eric@eric-laptop:~/cppcookbook$ ./a.out POSIX
>> > trying to access locale POSIX
>> > Generated locale C
>> > Error when writing to file
>> > eric@eric-laptop:~/cppcookbook$ ./a.out C
>> > trying to access locale C
>> > Generated locale C
>> > Error when writing to file
>> > eric@eric-laptop:~/cppcookbook$ ./a.out B
>> > trying to access locale B
>> > Couldn't generate locale B: locale::facet::_S_create_c_locale name not
>> > valid
>> > Error when writing to file
>> > eric@eric-laptop:~/cppcookbook$
>> > -------------------------------------------------------
>>
>>
>> Did you ever answer the question of which OS you're using?
>>
>> Your gcc is using --enable-clocale=generic so doesn't support named
>> locales in the C++ library.
>>
>> You could try running your code with a different global locale, i.e.
>>
>> LANG=en_US.utf8 ./a.out
> ----------------------------------------------------------------
> thanks your suggestion,
> here is the result of my test on your suggestion and what kind of I use
> ----
> eric@eric-laptop:~/cppcookbook$ LANG=en_US.utf8 ./a.out
> trying to access locale el_GR.utf8
> Couldn't generate locale el_GR.utf8: locale::facet::_S_create_c_locale
> name not valid
> Error when writing to file
> eric@eric-laptop:~/cppcookbook$ uname -r
> 2.6.35-25-generic
> eric@eric-laptop:~/cppcookbook$
> (Ubuntu/linux 10.04 upgrade kernel to 2.6.35-25)

Your GCC seems to be using --enable-clocale=generic on GNU/Linux,
which makes no sense.

What does 'gcc -v' print?

> I also modify from el_GR to en_US in en_US.utf8
> then ./a.out (or LANG=en_US.utf8 ./a.out          , same error)
> trying to access locale en_US.utf8
> Couldn't generate locale en_US.utf8: locale::facet::_S_create_c_locale
> name not valid
> Error when writing to file

This will not work, you cannot load any named locale with your version of gcc.

My suggestion is to run the original program to write unicode to file
(not this test program) with LANG=en_US.utf8



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux