[Bug libstdc++/33852] incorrect text formating in "std::cout" with UTF-8

pcarlini at suse dot de gcc-bugzilla@gcc.gnu.org
Sun Oct 28 09:53:00 GMT 2007



------- Comment #3 from pcarlini at suse dot de  2007-10-28 09:53 -------
Cout & co by default aren't converting streams, they are synced char-by-char
with stdio, therefore cannot be expected to work with UTF-8 in any meaningful
way. If you call sync_with_stdio(false) at the beginning of your program and
then imbue the proper locale, things will work with any encoding >= 0 locale,
UTF-8 or other, if you make sure to use wchar_t as your internal representation
(we do not provide char <-> char codecvts).

Note that a lot about locale and streams is implementation defined in the
current standard and we consider our design choices (sync with stdio by
default, required in the standard, then a converting stream if syncing is
disabled) only a very good compromise.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33852



More information about the Gcc-bugs mailing list