0

尝试将宽字符写入文件时,我的 wofstream 被截断。

my_file << L"something";

wstring foo = //get a value from the registry ..

// foo contains 您好

my_file << foo;

my_file << "stuff that will never be seen";
4

1 回答 1

0

badbit(或其他错误位)正在您的流中设置,使其对之后的任何操作都无用。这可能是实现定义行为的边界(尤其是对于wchar_ts)。它只是不会按照你想要的方式工作。

错误的最大可能性是字符不适合一个 2-byte wchar_t,这使 Microsoft 的 STL 窒息。

于 2011-10-26T21:05:15.553 回答