Re: std::cout << Glib::ustring(utf8_literal) throws exception



On Sun, 2008-07-13 at 00:48 -0700, Sohail Somani wrote:
> Murray Cumming wrote:
> > On Sat, 2008-07-12 at 19:15 -0700, Sohail Somani wrote:
> >> Yes, you are right. Copying the ustring to a std::string gets rid of the 
> >> error but still doesn't work right because it is interpreted as ASCII in 
> >> the console.
> > 
> > std::cout does not understand UTF-8. That's why glibmm tries to do a
> > conversion (with the Glib::convert_*() functions. That's documented by
> > the way:
> > http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1ustring.html#_details
> > 
> > But I don't know why the conversion is failing in your case. Maybe it's
> > a problem with the glib installation on windows.
> 
> Isn't the whole point of UTF-8 that std::cout doesn't need to understand it?
> 
> Shouldn't it be the console (or whatever is reading the output) who 
> tries to understand it?

No, I don't think that's how it works, though I guess that would be
nice. I'm quite sure that something in C++ standard streams assumes that
one character is one byte.

It's a pity that C++ _still_ doesn't have UTF-8 support in its standard,
or apparently any sign that it will get into the standard any time soon.

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com



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