This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: wfstream::get() function and multibyte encoding
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "Joseph D. Wagner" <theman at josephdwagner dot info>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Mon, 21 Jun 2004 10:49:52 +0200
- Subject: Re: wfstream::get() function and multibyte encoding
- References: <000201c45739$18cfcb00$0201a8c0@joe>
Hi,
Joseph D. Wagner wrote:
The get() function on a wfstream object, at least the way I am using it, still fetches only 1 byte. I would have though get() on wfstream would fetch sizeof(wchar_t). I am aware that different overloaded versions of get() can fetch multiple characters, but is there a switch, setting, or option to tell the get() function to fetch sizeof(wchar_t) instead of just a single byte?
What actually happens when get() is invoked depends on many different
factors and, definitely, you cannot say in general that it fetches a
given number of bytes. Neither there is a switch, option or setting to
this effect.
In general, if you are using an unbuffered stream synchronized with
stdio (the default for cin, cout, etc...) each individual get boils down
to the system call getwc, whose behavior depends on the global locale
(as set by setlocale). If, on the other hand, you are using a wfstream,
then the conversion machinery prescribed by the Standard, and based on
the codecvt facet, is in effect and you can change it via imbue,
basically. In this case, I/O actually happens via a buffer which is
converted from/to the external representation by the codecvt facet.
Remember that for all those options to work well and correctly wrt the
Standard you need gcc3.4.0.
Paolo.