unicode-string

How I can print the wchar_t values to console?

不问归期 提交于 2019-11-26 03:41:40
问题 Example: #include <iostream> using namespace std; int main() { wchar_t en[] = L\"Hello\"; wchar_t ru[] = L\"Привет\"; //Russian language cout << ru << endl << en; return 0; } This code only prints HEX-values like adress. How to print the wchar_t string? 回答1: Edit: This doesn’t work if you are trying to write text that cannot be represented in your default locale. :-( Use std::wcout instead of std::cout . wcout << ru << endl << en; 回答2: Can I suggest std::wcout ? So, something like this: std: