Re: gtkmm 4: Glib::ustring: implicit conversions with streams
On 20 December 2016 at 09:26, Kjell Ahlstedt wrote: > > The conversions done by Glib::ustring are reasonable, at least if the read > or written stream uses the global locale. A std::locale contains a codecvt > facet, used for converting between one character encoding in the stream > (file) and a possibly different character encoding in main memory. But > Glib::ustring shall always contain UTF-8 encoded characters, independent of > the stream's locale and codecvt facet. It's reasonable that ustring's > operator<<() and operator>>() convert between UTF-8 and the stream's main > memory encoding. I get horribly confused by C++ locales, and especially the character encoding parts, but I think streams expect to receive characters in the native character set, so I think using the global locale is correct. That gives you a conversion from UTF-8 to the native character set, which gives you something in the encoding that streams expect. When a stream wants to perform a conversion using its imbued locale it already knows how to do that, e.g. std::filebuf does that so that bytes written to a file are converted from the in-memory encoding to the on-disk encoding. But as I said, I find this stuff very confusing. ___ gtkmm-list mailing list gtkmm-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtkmm-list
Re: gtkmm 4: Glib::ustring: implicit conversions with streams
The conversions done by Glib::ustring are reasonable, at least if the read or written stream uses the global locale.A std::locale contains a codecvt facet, used for converting between one character encoding in the stream (file) and a possibly different character encoding in main memory. But Glib::ustring shall always contain UTF-8 encoded characters, independent of the stream's locale and codecvt facet. It's reasonable that ustring's operator<<() and operator>>() convert between UTF-8 and the stream's main memory encoding. The drawback with the present version of ustring is that it converts between UTF-8 and the encoding of the global locale, even if the stream uses another locale, set with std::ios_base::imbue(). I don't know if this can be improved with a reasonable effort. Kjell ___ gtkmm-list mailing list gtkmm-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtkmm-list
gtkmm 4: Glib::ustring: implicit conversions with streams
I guess now is the time to revisit this: https://mail.gnome.org/archives/gtkmm-list/2007-May/msg00061.html I think this is the bug comment that Daniel was referring to there: https://bugzilla.gnome.org/show_bug.cgi?id=93787#c3 Would anyone like to investigate and maybe prepare a patch? -- Murray Cumming murr...@murrayc.com www.murrayc.com ___ gtkmm-list mailing list gtkmm-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtkmm-list