0

VC++ 文档说:(在:http: //msdn.microsoft.com/en-us/library/tzf8k3z8 (VS.90 ) .aspx)对我来说非常奇怪

“basic_filebuf 类型的对象是使用 char * 类型的内部缓冲区创建的,无论类型参数 Elem 指定的 char_type 是什么。这意味着 Unicode 字符串(包含 wchar_t 字符)将在之前转换为 ANSI 字符串(包含 char 字符)它被写入内部缓冲区。要在缓冲区中存储 Unicode 字符串,请创建一个 wchar_t 类型的新缓冲区并使用 basic_streambuf::pubsetbuf() 方法设置它。要查看演示此行为的示例,请参见下文。

为什么?

4

1 回答 1

0

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...

于 2010-11-16T17:41:14.763 回答