The call of setlocale( LC_ALL, "" );
(with the second blank parameter), causes the default locale of the program to be set according to the variables of its environment.
If you are working with the Cirilico alphabet, surely the environment where you are running your program uses coding UTF-8
.
Follow your modified example:
#include <iostream>
#include <locale>
int main(){
setlocale( LC_ALL, "" );
wchar_t coisa[6];
coisa[0] = L'з';
coisa[1] = L'е';
coisa[2] = L'м';
coisa[3] = L'л';
coisa[4] = L'я';
coisa[5] = L'\0';
std::wcout << coisa << std::endl;
}
The coding UTF-8
covers virtually all existing alphabets, making the language an expendable detail:
#include <iostream>
#include <locale>
int main(){
setlocale( LC_ALL, "" );
std::wstring ch = L"你好世界";
std::wstring gk = L"γειά σου κόσμος";
std::wstring jp = L"こんにちは世界";
std::wstring ko = L"여보세요 세계";
std::wstring pt = L"Olá mundo!";
std::wstring ru = L"Здравствулте мир!";
std::wcout << L"Chinês : " << ch << std::endl;
std::wcout << L"Grego : " << gk << std::endl;
std::wcout << L"Japonês : " << jp << std::endl;
std::wcout << L"Coreano : " << ko << std::endl;
std::wcout << L"Português : " << pt << std::endl;
std::wcout << L"Russo : " << ru << std::endl;
}
Try:
setlocale(LC_ALL, "Russian");
– Francisco
I’ve tried...continues the same thing. Follow the code: #include <iostream> #include <locale. h> int main(){ setlocale(LC_ALL, "Russian"); char thing[6]; thing[0]='з'; thing[1]='е';'; thing[2]=';}
– user83187