This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: UTF-8 support - char or wchar_t?


Carlo Wood wrote:

Can you please explain why one needs wchar_t (wcout)
at all when using UTF-8?  I'd expect that UTF-8 fits
in a stream of 8-bit octets and no wchar_t should
be needed at all.

UTF-8 fits in a stream of 8-bit octets of the *external* encoding!
How do you produce this *external* UTF-8 encoded stream?

The standard way is using an *internal* wchar_t representation
(basically, on GNU systems is UCS4, see the glibc docs), then
exploiting the specialization codecvt<wchar_t, char, mbstate_t>.
Notice that, on the other hand, according to the Standard
(22.2.1.5, p3):

"codecvt<char, char, mbstate_t> implements a degenerate
 conversion; it does not convert at all."

Agreed?

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]