|
-
May 1st, 2003, 02:51 AM
#1
-
May 1st, 2003, 03:07 AM
#2
Re: Why TCHAR?
can anyone tell me the function of "TEXT" and "TCHAR"?
The most important ..Are you use that in your progamme?
TCHAR's are used because not all non-english characters can be found in the standard 8 bit, 256 character set which is what a CHAR is. A TCHAR is 16 bits so it's possible to encode a vast number of non-english characters.
I use them in my Pocket PC apps only because you have no choice but to. I don't use them at all in my Windows apps because they take up double the space and I've never seen a need for them. I've got "Programming Windows" too but I just ignore all the TCHAR stuff myself.
Sean.
Sean O'Connor
http://www.windowsgames.co.uk
-
May 1st, 2003, 03:19 AM
#3
TCHAR is used to simplify the porting of program from UNICODE and ANSI and vice versa.
for example you, you have a code like this.
Code:
char s1[100];
char s2[100];
char s2[100];
If you port this to UNICODE (eg. CE App) you have to change it to this
Code:
WCHAR s1[100];
WCHAR s2[100];
WCHAR s2[100];
To simplify it, you define it using TCHAR, for ANSI, just make this
Code:
TCHAR s1[100];
TCHAR s2[100];
TCHAR s2[100];
to make it a UNICODE program, add this to your code
and the compiler will do the conversion from char[100] to WCHAR[100]
That's how it works. The TEXT works the same
Hope this will help you
Last edited by rxbagain; May 1st, 2003 at 03:22 AM.
-
May 1st, 2003, 07:37 AM
#4
Thank all of you very much ...
helps me a lot
I'm a newbie .. Known little about windows programming ...
Leaning SDK and then any Rad tools 
-
May 1st, 2003, 10:55 PM
#5
rxbagain, your post is really good!
But I still have some questions:
When shall I use the unicode?
What's the default for Windows english version, ASCII or unicode?
Any difference between Windows 9X, 2000 and XP?
Thanks!
-
May 1st, 2003, 11:09 PM
#6
Win9X by uses the MutiByte character code (ASCII).
NT platforms (NT, 2000, XP) uses UNICODE by default, but u can as well use the Multibyte characters in your program
CE uses only UNICODE.
Unicode programming is used if you want to make a program that will run on UNICODE systems (NT, 200, XP, CE). This will limit your system targets but it will make faster for your program to manipulate strings because it there is no need for the system to translate from ASCII to UNICODE and vice versa.
Hope this will clarify your concern.
-
May 1st, 2003, 11:30 PM
#7
-
May 5th, 2003, 12:08 PM
#8
Re: Re: Why TCHAR?
Originally posted by Sean O'Connor
I don't use them at all in my Windows apps because they take up double the space and I've never seen a need for them.
This is not true. (Well, you may not see a need for TCHARs, but the first part...)
In an ANSI build, a TCHAR is just like a char, and does not take up extra space. In a UNICODE build, true, then the TCHARs are converted to wide chars, and take up the extra space. But presumably, you would only build your project in UNICODE if you needed to support unicode. Sure, wide chars take up extra space, but they are worth it if you want to support any language.
Personally, I only use TCHARs and WCHARs, I never use straight char's anymore.
Henri Hein
Principal Engineer, Propel
Do not credit Propel with my views or opinions.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|