468,484 Members | 1,749 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

what is wchar_t


Hi ,
Can anyone please explain what are wide characters (wchar_t).
Why is it used when there is char datatype ?

Regards,
Sarathy

Jul 28 '06 #1
4 12125
sarathy wrote:
Hi ,
Can anyone please explain what are wide characters (wchar_t).
Why is it used when there is char datatype ?
It's the 'w'ide 'char'acter 't'ype. A constant example would be L'X'.

See wchar.h, added with Amendment 1.
Jul 28 '06 #2
sarathy wrote:
Hi ,
Can anyone please explain what are wide characters (wchar_t).
Characters with more than 256 possible values
Why is it used when there is char datatype ?
char is limited to 256 possible values, on most computers.
In order to write text in other languages, you need many
more possible characters.

Jul 29 '06 #3
"Old Wolf" <ol*****@inspire.net.nzwrites:
sarathy wrote:
> Can anyone please explain what are wide characters (wchar_t).

Characters with more than 256 possible values
Well, char can have more than 256 possible values if CHAR_BIT 8.

For that matter, I don't think there's any guarantee that wchar_t
actually can represent more than 256 values, though it's fairly
pointless if it can't.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 29 '06 #4
Keith Thompson wrote:
"Old Wolf" <ol*****@inspire.net.nzwrites:
sarathy wrote:
Can anyone please explain what are wide characters (wchar_t).
Characters with more than 256 possible values

Well, char can have more than 256 possible values if CHAR_BIT 8.

For that matter, I don't think there's any guarantee that wchar_t
actually can represent more than 256 values, though it's fairly
pointless if it can't.
There's not any guarantee that wchar_t can represent more than 255
values, if it is signed. I wouldn't call it pointless though: code
shouldn't have to check whether wchar_t is defined, and use char if it
isn't. You can simply assume wchar_t exists, and if the implementation
does not support multibyte characters, the code will still work as well
as possible. Pretty much every important string function has both a
narrow and a wide string version, and every one would have to be
wrapped in a #if USE_WCHAR_T block otherwise.

Jul 29 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Marcin Kalicinski | last post: by
23 posts views Thread by Steven T. Hatton | last post: by
12 posts views Thread by Jens Theisen | last post: by
8 posts views Thread by Rui Maciel | last post: by
1 post views Thread by Rui Maciel | last post: by
1 post views Thread by George2 | last post: by
16 posts views Thread by Michael Brennan | last post: by
5 posts views Thread by Samant.Trupti | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.