Bug 10534 - wcout can only print ASCII,can't print other language,eg. chinese.
Summary: wcout can only print ASCII,can't print other language,eg. chinese.
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.2.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-29 08:46 UTC by dragzhb
Modified: 2006-10-20 09:28 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dragzhb 2003-04-29 08:46:00 UTC
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 &#20013;&#22269;";
	wcout << "src: " << src << endl;	

}

Release:
gcc-3.2.2

Environment:
redhat linux 9.0
Comment 1 Pétur Runólfsson 2003-08-18 13:43:51 UTC
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.
Comment 2 Andrew Pinski 2003-08-18 13:47:34 UTC
Test is invalid as explained in the previous comment.
Comment 3 Benjamin Kosnik 2006-10-20 09:28:11 UTC
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;
}