Before you can even begin the task of creating text files containing non-Latin characters, you have to determine which encoding to be used for your locale.
For example, if your locale uses the UTF-8
encoding, the string "русский" will have to be encoded completely differently than if your locale is KOI8-R
.
The string "русский" in UTF-8
is represents by the octets (bytes): d1 80 d1 83 d1 81 d1 81 d0 ba d0 b8 d0 b9
. For a KOI8-R
locale, the equivalent octets are d2 d5 d3 d3 cb c9 ca
.
Internationalization is hard.
In most cases you might be able to use the C++ library's wide character streams with unicode:
#include <iostream>
#include <locale>
int main()
{
std::locale::global(std::locale(""));
std::wcout << L"\u0440\u0443\u0441\u0441\u043a\u0438\u0439" << std::endl;
return 0;
}
Hopefully, the output from this will be "русский", on your platform. Provided this works, this might be the path of least resistance, but you will have to look up the unicode values for each character.
There's also support for UTF-8
in the new C++ standard, but the answer here is for you to spend some time educating yourself on the general concepts of locale, unicode, and internationalization. It will be difficult to do this right without a complete understanding of how all of these things work.