Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2007-05-25 11:17:00


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?
>
> Thanks,
> Filip
>
> // _UNICODE must be defined; the "2" is never printed.
> #include <string>
> #include <iostream>
> #include <sstream>
> #include <locale.h>
>
> #include <boost/date_time/posix_time/posix_time.hpp>
> using boost::posix_time::ptime;
> using boost::date_time::not_a_date_time;
>
> int main() {
> wstring intl=L"\x161";
> wostringstream ss;
> ss << ptime(not_a_date_time);
> wcout << ss.str() << endl;
> wcout << intl << endl;
> wcout << L"1" << endl;
> wcout << ptime(not_a_date_time) << endl;
> wcout << intl << endl;
> wcout << L"2" << endl;
> }

No ideas. I suspect this is a bad interaction between streams and terminal
i/o...somehow the unicode output is making the subsequent data invisible or
something. You could change the characters used for not_a_date_time in the
facet and see if that makes things better, but no telling when you'd run into
this in some other context.

Jeff


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