473,382 Members | 1,658 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,382 software developers and data experts.

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 12434
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark Fancy | last post by:
I have a project that I'm trying to get to compile. I need to have the /Tc:wchar_t compile switch in order to use some libraries. I have included the following header files: #include <mapix.h>...
1
by: Marcin Kalicinski | last post by:
wchar_t c1 = wchar_t('A'); wchar_t c2 = L'A'; Is c1 equal to c2? If they are not equal, how can I create wchar_t character representing the same character as some char value? cheers,...
23
by: Steven T. Hatton | last post by:
This is one of the first obstacles I encountered when getting started with C++. I found that everybody had their own idea of what a string is. There was std::string, QString, xercesc::XMLString,...
12
by: Jens Theisen | last post by:
Hello, does anyone know which layer is responsible for defining the size of wchar_t? Naturally enough, it's not defined in the language. I looked in the SystemV processor supplement and the...
8
by: Rui Maciel | last post by:
I've just started learning how to use the wchar_t data type as the basis for Unicode strings and unfortunately I'm having quite a bit of problems, both in the C front and the Unicode front. In...
1
by: Rui Maciel | last post by:
I'm trying to use the getwc() function to get individual characters from a stream but I've stumbled on a type conversion problem. The getwc() function returns a type wint_t instead of a wchar_t and...
1
by: George2 | last post by:
Hello everyone, Here is the code, and if I change line from static wchar_t* p = {PREFIX((wchar_t*)_TEXT("FOO"))}; to static wchar_t* p = {PREFIX(_TEXT("FOO"))};
16
by: Michael Brennan | last post by:
I guess this question only applies to programming applications for UNIX, Windows and similiar. If one develops something for an embedded system I can understand that wchar_t would be unnecessary. ...
5
by: Samant.Trupti | last post by:
Hi, There is one thing I am cofused about.... If I have a declareation say char str; Now if I want to change it to wchar so do I have to change it like .... wchar_t str; or double the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.