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: wfstream::get() function and multibyte encoding


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.


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