开发者

How come VC++ 2010 uses char buffer rather than wchar_t buffer to represent basic_filebuf<wchar_t>?

It is very very strange to me that the VC++ docs says: (at: http://msdn.microsoft.com/en-us/library/tzf8k3z8(VS.90).aspx)

"Objects of type basic_filebuf are created with an internal buffer of type char * regardless of the char_type specified by the type parameter Elem. This means that a Unicode string (containing wchar_t characters) will be converted to an ANSI string (containing char characters) before it is written to the internal buffer. To store Unicode strings in the buffer, create a new buffer of type wchar_t and set it using the basic_streambuf::pubsetbuf() method. To s开发者_如何学编程ee an example that demonstrates this behavior, see below."

Why?


This is only a guess but it may be this way to handle the common case (at least on Windows) where the program's internals are wchar_t (16-bit Unicode characters) but most/all text files it outputs are 8-bit ANSI.

Most text files still seem to be ANSI unless they really need to be otherwise, and many programs cannot cope properly with Unicode text files.

I wonder if it's really an ANSI string or a UTF-8 string that it converts to...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜