Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > what is wchar_t

Reply
Thread Tools

what is wchar_t

 
 
sarathy
Guest
Posts: n/a
 
      07-28-2006

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

Regards,
Sarathy

 
Reply With Quote
 
 
 
 
Clever Monkey
Guest
Posts: n/a
 
      07-28-2006
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.
 
Reply With Quote
 
 
 
 
Old Wolf
Guest
Posts: n/a
 
      07-29-2006
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.

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      07-29-2006
"Old Wolf" <(E-Mail Removed)> writes:
> 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) http://www.velocityreviews.com/forums/(E-Mail Removed) <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.
 
Reply With Quote
 
=?utf-8?B?SGFyYWxkIHZhbiBExLNr?=
Guest
Posts: n/a
 
      07-29-2006
Keith Thompson wrote:
> "Old Wolf" <(E-Mail Removed)> writes:
> > 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting from windows wchar_t to linux wchar_t yakir22@gmail.com C++ 3 08-15-2008 09:04 AM
wchar_t -> UTF-8? Jon Willeke C++ 2 02-09-2004 08:05 AM
std::wstring, TCHAR, wchar_t and LPTSTR sorty C++ 4 11-25-2003 11:05 AM
string class that can convert between wchar_t and char Bren C++ 4 10-07-2003 03:24 PM
wchar_t wstring char string transformations Adrian Cornish C++ 2 07-12-2003 08:05 PM



Advertisments