473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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
Jan 27 '06 #1
2 2005
* Raghu:
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?
Jan 27 '06 #2
TB
Raghu sade:
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
Jan 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Web Developer | last post by:
Hi, Have a book that says a char in c++ is 8bit wide. But i remember reading that C++ uses ANSI character set which uses 7bit per character. Who is right? WD
3
by: Jonathan Mcdougall | last post by:
I started using boost's filesystem library a couple of days ago. In its FAQ, it states "Wide-character names would provide an illusion of portability where portability does not in fact exist....
15
by: Steve | last post by:
Hi, I've been charged with investigating the possibilities of internationalizing our C++ libraries. std::strings are used all over the place, and unfortunately a mixture of...
3
by: yazan jab | last post by:
Is it true that Multibyte characters are : char arrays (witch represent a string from the basic characters set). In this case Wide characters are the way for encoding characters from the...
11
by: Roger Leigh | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The program listed below demonstrates the use of wcsftime() and std::time_put<wchar_t> which is a C++ wrapper around it. (I know this isn't C; but...
1
by: ajay.sonawane | last post by:
How can I find the wheather the occurance substring is main string in wide char provided that the compasion should be case insensitive.
4
by: uday.sen | last post by:
Hi, I need to convert a string from UTF8 to wide character (wchar_t *). I perform the same in windows using: MultiByteToWideChar(CP_UTF8, 0, pInput, -1, pOutput, nLen); However, in linux...
4
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?
9
by: toton | last post by:
Hi, I have my program using wstring everywhere instead of string. Similarly I need to process some file, which contains unicode or ascii character. I need to stream them. Thus I use wifstream etc....
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.