By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,666 Members | 1,544 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,666 IT Pros & Developers. It's quick & easy.

wcout does not print wide character string in solaris.

P: n/a
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.

Dec 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
iwongu wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.