#include <iostream>
int main(){
char coisa[6];
coisa[0]='з';
coisa[1]='е';
coisa[2]='м';
coisa[3]='л';
coisa[4]='я';
std::cout << coisa << "\n";
}
#include <iostream>
int main(){
char coisa[6];
coisa[0]='з';
coisa[1]='е';
coisa[2]='м';
coisa[3]='л';
coisa[4]='я';
std::cout << coisa << "\n";
}
Calling setlocale( LC_ALL, "" );
(with the second parameter blank), causes the default locale of the program to be set to the variables of your environment.
If you are working with the Cyrillic alphabet, certainly the environment where you are running your program uses the UTF-8
encoding.
Here is 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'#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;
}
';
std::wcout << coisa << std::endl;
}
The UTF-8
encoding covers practically all existing alphabets, making the language a dispensable detail:
#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'#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;
}
';
std::wcout << coisa << std::endl;
}