What are the proper facilities to be using for full unicode in C++?
For example, I have tried:
int main()
{
std::wstring name;
std::wcout << "Enter unicode: " << std::endl;
std::getline(std::wcin, name);
std::wcout << name << std::endl;
return 0;
}
And it doesn't work as I would expect when entering the character: or others that are not in the Unicode BMP. I get an empty line printed out.
Plain string works for any code points up to 16bits, wstring, wcin, wcout just don't work as I'd expect and some Googling hasn't helped me see what about this could be wrong.
EDIT (file I/O also has issues!):
I wondered if this could have something do with with the console I/O itself and wanted to try the same for file I/O as an experiment. I looked into the api's and came up with this which compiles and runs fine:
int main()
{
std::string filename;
std::cout << "Enter file to append to: " << std::endl;
std::getline(std::cin, filename);
std::wifstream file;
std::wstringstream buff;
file.open(filename);
std::wstring txt;
buff << file.rdbuf();
file.close();
txt = buff.str();
std::wcout << txt << std::endl;
return 0;
}
But when I point it to my file with mostly lorem ipsum and a few non-BMP characters, it prints the file up to the first non-BMP character and then stops early. Can the Unicode facilities in modern C++ really be this bad?
I'm sure someone knows something basic I am missing here...