#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;
}
Asked
Active
Viewed 1,964 times
1
ST3
- 8,410
- 3
- 64
- 90
Šimon Tóth
- 34,358
- 19
- 97
- 147
2 Answers
3
It's your system. Locale names are not part of the C++ standard, so "en_US.UTF-8" is not universally valid. It's not even certain that a locale similar to it exists.
MSalters
- 167,472
- 9
- 150
- 334
2
Won't work in an embedded system without a file system.
Or without that locale installed, of course.
CashCow
- 29,989
- 4
- 56
- 89