|
Boost Users : |
From: Filip KonviÄka (filip.konvicka_at_[hidden])
Date: 2007-05-26 18:01:44
Kirit Sælensminde 26.5.2007 5:35:
> Filip KonviÄka wrote:
>
>> Hi,
>>
>> in MSVC 8.0 _UNICODE build, after I send a ptime to wcout, I can no
>> longer print "international" characters. When I use a temporary
>> wostringstream for printing the ptime, everything is OK. Minimal repro
>> see below (the "2" at the end is never printed). With some characters
>> like the "Å¡" in the example, the output is totally cut off; with others,
>> like "á", the codepage is changed, so the characters are displayed
>> incorrectly.
>>
>> Any suggestions?
>>
>
> This is a problem in the MSVC libraries. If you print a character above
> code 255 then the stream crashes and is good for nothing afterwards.
> Only std::wstringstream doesn't have this problem.
>
> I think if you buy the Dinkumware libraries this works. The _cputws
> function does work as you would expect, but it can't be piped. The
> behaviour also changes if you run the program from a command shell with
> Unicode turned on ( cmd.exe /u).
>
> I did talk to PJ Plauger about it on clc. This is what he explained:
>
> "When you write to a wofstream, the wchar_t sequence you write gets
> converted to a byte sequence written to the file. How that conversion
> occurs depends on the codecvt facet you choose. Choose none any you get
> some default. In the case of VC++ the default is pretty stupid -- the
> first 256 codes get written as single bytes and all other wide-character
> codes fail to write. "
>
> http://groups.google.com/group/comp.lang.c++/browse_thread/thread/3c203253708befb5/1bc5d68887f1a72d?lnk=st&q=&rnum=107
>
How do you explain that the workaround works, then? When I don't send
any ptime to wcout, all wcin / wcout i/o works as expected, including
international characters (all I do is call setlocale(LC_ALL, ".OEM"); at
startup).
Filip
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net