wcout does not print wide character string in solaris.

I

iwongu

Hi,

I have a question about std::wcout and its underlying C functions.

According to C99, a stream have an orientation type that is one of
byte-oriented or wide-one, and it is determined by the first using C
function on that stream. And the specific orientation functions should
not be applied to the stream that have other orientation.


And, the follwing code is working; (gcc 3.4.3 in solaris 10 x86)

wcout << "abcd" << endl;
wcout << "한글efgh" << endl; // the first four bytes are Korean
// characters.
wcout << "ijkl" << endl;

The result is;

abcd
한글efgh
ijkl


But the following is not.

wcout << L"abcd" << endl;
wcout << L"한글efgh" << endl;
wcout << L"ijkl" << endl;

The result is;

abcd

All characters are not printed after I try to print Korean.

I assumed that wcout might use byte-function (not wide-) to print
narrow characters even though it is wide character string literal. So
the stdout had byte-orientation and the rest are not printed because
they are wide-oriented function. But this assumption can not explain
the
last line; L"ijkl".

I tried more code.


wcout << "abcd" << endl;
wcout << L"한글efgh" << endl;
wcout << "ijkl" << endl;


The result is;

abcd

:-|


wcout << "abcd" << endl;
wcout << L"한글efgh" << endl;
cout << "ijkl" << endl; // <-- changed to cout

The result is;

abcd
ijkl


Is this a bug in compiler? What's the standard-correct output for this?

Thanks in advance.

iwongu.
 
V

Victor Bazarov

iwongu said:
I have a question about std::wcout and its underlying C functions.

Who told you it has underlying C functions? :)
According to C99, a stream have an orientation type that is one of
byte-oriented or wide-one, and it is determined by the first using C
function on that stream. And the specific orientation functions should
not be applied to the stream that have other orientation.


And, the follwing code is working; (gcc 3.4.3 in solaris 10 x86)

wcout << "abcd" << endl;
wcout << "??efgh" << endl; // the first four bytes are Korean
// characters.

You cannot have those characters in the source file. They have to
be \U-encoded, IIRC.
wcout << "ijkl" << endl;

[..]

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top