#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
locale system("");
locale::global(system);
wcin.imbue(system);
wstring data;
getline(wcin,data);
wcout.imbue(system);
wcout << data << L" length=" << data.length() << endl;
locale utfFile("en_US.UTF-8");
wofstream file("my_utf_file.txt");
file.imbue(utfFile);
file << data;
file << endl;
file.close();
return 0;
}
答案 0 :(得分:3)
这是你的系统。区域设置名称不是C ++标准的一部分,因此"en_US.UTF-8"
不是普遍有效的。甚至不确定是否存在类似于它的语言环境。
答案 1 :(得分:2)
如果没有文件系统,将无法在嵌入式系统中运行。
或者当然没有安装该语言环境。