相关疑难解决方法(0)

为什么C++中的宽文件流默认会缩小写入数据?

老实说,我只是没有在C++标准库中得到以下设计决定.将宽字符写入文件时,将wofstream转换wchar_tchar字符:

#include <fstream>
#include <string>

int main()
{
    using namespace std;

    wstring someString = L"Hello StackOverflow!";
    wofstream file(L"Test.txt");

    file << someString; // the output file will consist of ASCII characters!
}
Run Code Online (Sandbox Code Playgroud)

我知道这与标准有关codecvt.还有codecvtutf8Boost.此外,还有一个codecvt用于utf16马丁·约克在这里SO.现在的问题是,为什么standard codecvt转换宽字符?为什么不按原样写人物!

另外,我们是否会unicode streams使用C++ 0x或者我在这里遗漏了什么?

c++ unicode file wofstream

18
推荐指数
2
解决办法
7938
查看次数

标签 统计

c++ ×1

file ×1

unicode ×1

wofstream ×1