This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/33852] incorrect text formating in "std::cout" with UTF-8
- From: "pcarlini at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Oct 2007 09:53:10 -0000
- Subject: [Bug libstdc++/33852] incorrect text formating in "std::cout" with UTF-8
- References: <bug-33852-15016@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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