wcout can only print ASCII,can't print other language,eg. chinese. this bug exist in gcc 3.1.* and 3.2.*, I have report this bug in gcc3.2 bug No. 8104. The following is source code. #include <iostream> using namespace std; int main(int argc, char** argv) { const wchar_t* src = L"hello 中国"; wcout << "src: " << src << endl; } Release: gcc-3.2.2 Environment: redhat linux 9.0
The test case is broken. In order to output non-ascii characters with wcout, the global locale must be set correctly before the first output operation. The bug used to be real though, but should be fixed on mainline.
Test is invalid as explained in the previous comment.
Ie: #include <iostream> int main() { using namespace std; const wchar_t w1 = { 0x4e2d };// U+20013 == 0x4E2D const wchar_t w2 = { 0x56fd };// U+22269 == 0x56FD const wchar_t w3(20013); const wchar_t w4(22269); locale loc("zh_CN.utf8"); locale::global(loc); wcout << w1 << endl; wcout << w2 << endl; wcout << w3 << endl; wcout << w4 << endl; return 0; }