gpt4 book ai didi

c++ - 此代码是否通用,还是仅适用于我的系统?

转载 作者:行者123 更新时间:2023-11-30 01:30:31 25 4
gpt4 key购买 nike

#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++ 标准的一部分,因此 "en_US.UTF-8" 不是普遍有效的。甚至不确定是否存在与它相似的语言环境。

关于c++ - 此代码是否通用,还是仅适用于我的系统?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4324385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com