473,785 Members | 3,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wcout does not print wide character string in solaris.

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
1 3607
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3076
by: Alex Mizrahi | last post by:
Hello, All! i admit that it's better to ask questions connected with atl/mfc classes in special newsgroups, but seems like people there are interested more in discussing stuff like MFC GUI than C++ 8-/, so i'll better ask here too.. CStringW is a class in atl/mfc dealing with strings 8-]. the only typecast operator i found is to PCXSTR that is LPCWSTR that is simply "const unsigned short*" (wchar_t is unsigned short). wcout accepts...
15
11011
by: wizardyhnr | last post by:
i want to try ANSI C99's unicode fuctions. so i write a test program. the function is simple, but i cannot compile it with dev c++ 4.9.9.2 under windows xp sp2, since the compiler always think that the initialization of the wchar_t string is illegal. here is my function: #include <stdio.h> #include <stdlib.h> #include <wchar.h> #include <wctype.h> #include <string.h>
4
17786
by: thinktwice | last post by:
i'm using VC++6 IDE i know i could use macros like A2T, T2A, but is there any way more decent way to do this?
2
8395
by: interec | last post by:
I have a simple program in which I want to read a wstring using wcin and then output the same string using wcout. The program takes a few words separated by spaces as input. The problem is that only the first word is outputted. Everything after the first space seems to be lost in the output. My OS is redhat hat linux 4 ES. gcc 3.4.6. How do I fix this and why its not working? Thanks Code
2
7779
by: Ralf Goertz | last post by:
Hi, can I mix output to cout and wcout? It seems that if I write to cout first it works fine but if I start with wcout the output to cout vanishes. I assume that is has to do with the initialization of standard output, right? #include <iostream> using namespace std;
2
3897
by: year1943 | last post by:
There was the same topic not so long ago, but as I see it stays w/o answer: http://groups.google.ru/group/comp.lang.c++/browse_thread/thread/9a05d7bba9394a60/fe109c899f916871?lnk=gst&q=locale+imbue&rnum=1&hl=ru#fe109c899f916871 As Bjarne Stroustrup said in his book, "in Stroustrup (retranslated from German) "Setting the global locale does not affect existing input/output streams. The streams continue to use those locales that were...
44
4386
by: Ioannis Vranos | last post by:
Has anyone actually managed to print non-English text by using wcout or wprintf and the rest of standard, wide character functions?
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.