C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to use wide char

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Raghu
Guest





PostPosted: Fri Jan 27, 2006 11:09 am    Post subject: How to use wide char Reply with quote



Hello all,

I want to know how can we print special characters like ä / ö /etc., on the
console.
I mean, if i want to print a string containing one of these characters
(eg. hällö) how to use wide character data type?

Thanks in advance

Regards
Raghu


Back to top
Alf P. Steinbach
Guest





PostPosted: Fri Jan 27, 2006 11:17 am    Post subject: Re: How to use wide char Reply with quote



* Raghu:
Quote:
Hello all,

I want to know how can we print special characters like ä / ö /etc., on the
console.
I mean, if i want to print a string containing one of these characters
(eg. hällö) how to use wide character data type?


If your compiler supports std::wcout (which g++ for Windows doesn't
currently do) simply use std::wcout instead of std::cout.

At least, that's the theory.

In practice it may not work anyway, because std::wcout performs a
conversion and the end result may not be what your console facility
expects; in that case, you can use platform-specific functionality,
and/or you can try to fiddle with the conversion (never tried it).

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Back to top
TB
Guest





PostPosted: Fri Jan 27, 2006 12:41 pm    Post subject: Re: How to use wide char Reply with quote



Raghu sade:
Quote:
Hello all,

I want to know how can we print special characters like ä / ö /etc., on the
console.
I mean, if i want to print a string containing one of these characters
(eg. hällö) how to use wide character data type?

Thanks in advance


You don't need to. Latin-1 codes can be represented using
a normal 'char'. But if your host console uses another
character set (not unicode), then you might get something else,
like if it uses any of windows own abnormal charsets. And if
you're using any of the other Latin-charset, some translation
might also be required, depending on your host environment.

std::cout<<"hällö";

'ä' in both Latin-1 and Unicode has the code number 228.

char aa = 229; // 'ä'
wchar_t waa = 229; // 'ä'

And use an editor that supports unicode or Latin-1.

--
TB @ SWEDEN

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.