【问题标题】:Does this code work universaly, or is it just my system?这段代码是通用的,还是只是我的系统?
【发布时间】:2011-05-18 11:39:31
【问题描述】:
#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;
}

【问题讨论】:

    标签: c++ unicode utf-8 locale wofstream


    【解决方案1】:

    无法在没有文件系统的嵌入式系统中工作。

    当然,或者没有安装该语言环境。

    【讨论】:

      【解决方案2】:

      这是你的系统。语言环境名称不是 C++ 标准的一部分,因此 "en_US.UTF-8" 不是普遍有效的。甚至不确定是否存在与其相似的语言环境。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-08
        • 2017-07-24
        • 1970-01-01
        • 2023-03-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多