Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 4th, 2007, 11:33 AM   #1
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 203
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
Wide characters

Hi,

I was just wondering what the heck a wide character was? I've never needed to use one....

Thanks very much,

Matt. I
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Dec 4th, 2007, 11:52 AM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Wide characters

Wikipedia is your friend: Wide Characters.

Essentially, it is a datatype used to store any character that could not otherwise be stored with the regular "char" datatype. This is because the number of bits used to distinguish a wide character from other characters exceeds the number of bits that a normal character datatype can store. The specifics of this are beyond me.
Sane is offline   Reply With Quote
Old Dec 4th, 2007, 4:02 PM   #3
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 549
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: Wide characters

wide characters are used in UNICODE programs, which are programs written for most any language such as Chinese, Japanese, German, Frensh, etc. etc. Many characters in non-English languages can't be represented in one char data type. There is actually a UNICODE standard which specify the width of a UNICODE character and functions to manipulate them, and convert from char* to wchar_t*. The Microsoft compilers have a large set of macros to convert function calls between UNICODE and non-UNICODE compiles. If you use these macros you can compile with or without UNICODE with nearly no changes in the source code.
Ancient Dragon is offline   Reply With Quote
Old Dec 4th, 2007, 5:02 PM   #4
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 203
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
Re: Wide characters

Brilliant! Thank you very much for your help!
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Dec 4th, 2007, 6:09 PM   #5
Kuryn
Newbie
 
Join Date: Dec 2007
Posts: 14
Rep Power: 0 Kuryn is on a distinguished road
Re: Wide characters

Also its consider better to use wide characters than ansi characters. The reason why is that behind the scenes, the compiler has to convert from unicode to ansi each time. Which causes a performance hit. So when you build applications always you unicode to be safe from the performance hit on non-unicode apps
Kuryn is offline   Reply With Quote
Old Dec 4th, 2007, 6:59 PM   #6
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 549
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: Wide characters

>>The reason why is that behind the scenes, the compiler has to convert from unicode to ansi each time
No it does not do that, unless you are using some wierd compiler which does that on its own. The compiler uses UNICODE wide characters only if you define UNICODE in your program. Otherwise it uses standard char ascii character set.

>>So when you build applications always you unicode to be safe from the performance hit on non-unicode apps

Maybe what you mean is that the operating system makes that conversion. I don't know whether that is true or not because I don't know the internals of the MS-Windows operating systems.
Ancient Dragon is offline   Reply With Quote
Old Dec 4th, 2007, 7:41 PM   #7
Kuryn
Newbie
 
Join Date: Dec 2007
Posts: 14
Rep Power: 0 Kuryn is on a distinguished road
Re: Wide characters

Quote:
However, there are several disadvantages to this. First, calling ANSI functions on NT family systems incurs a performance hit, as the string parameters have to be translated on the way into and/or out of the call to the Unicode version of the function.

Second, the reason Unicode was invented in the first place was to allow for the expression of a wide spectrum of languages within a single character encoding. Sticking to ANSI will leave you back in the field of code-pages, and a limited set of supported languages. Finally, there are several technologies in Windows, most notably COM, that are Unicode only. If you write ANSI-only programs, you will have a lot of conversions to perform, which also impact on performance.
http://www.ddj.com/windows/184416713

look for single built ansi
Kuryn is offline   Reply With Quote
Old Dec 4th, 2007, 9:08 PM   #8
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 549
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: Wide characters

I believe that is talking about the operating system, not the compiler. Yes, all versions of WinCE and Mobile 5.0 systems are pure (almost) UNICODE, that is, most of the windows api functions and classes required UNICODE. The compiler for those operating systems still support ascii characters just as any other standard c++ compiler does. I worked with these for 10 years. Windows NT thru Vista support UNICODE but do not require it. In order to display a character on the screen the os probably does convert it to unicode, but the compiler has nothing to do with that.

As for COM, it doesn't require UNICODE either, it can transfer ascii characters just as easily as UNICODE (or bstr). And a bstr can be either unicode or ascii, depending on how the program wants to interpret it.

Last edited by Ancient Dragon; Dec 4th, 2007 at 9:20 PM.
Ancient Dragon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Regular Expression: Matching All Possible Characters kruptof PHP 3 May 30th, 2007 6:22 PM
Replacing characters in std::string magnus.therning C++ 10 Feb 1st, 2007 9:11 AM
2 dimension array of characters brad sue C 8 Mar 15th, 2006 9:40 AM
Converting ANSI characters to hex for Checksum. JawaKing00 C 4 Sep 9th, 2005 5:07 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:24 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC