 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Raghu Guest
|
Posted: Fri Jan 27, 2006 11:09 am Post subject: How to use wide char |
|
|
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
|
Posted: Fri Jan 27, 2006 11:17 am Post subject: Re: How to use wide char |
|
|
* 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
|
Posted: Fri Jan 27, 2006 12:41 pm Post subject: Re: How to use wide char |
|
|
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 |
|
 |
|
|
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
|
|