Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC ATL
the size of buffer through API returned descriped in MSDN,sometimes in character, sometimes in TCHARs, could you tell me the different between in characters and in TCHARs(on UNICODE project or on multibyte project).
Posted 25-Mar-11 6:56am
Edited 25-Mar-11 9:30am
v2
Comments
Richard MacCutchan at 25-Mar-11 13:40pm
   
I don't know who voted this down or why; it seems a perfectly reasonable question.
Nuri Ismail at 25-Mar-11 14:00pm
   
Yes, you are right Richard. His question is reasonable.
 
Maybe the fact that the answer could be easily found with a simple search motivated this down-vote, but the question is not a code request, therefore IMHO it does not deserve this down-vote.
 
I'll try to compensate with a 5, too.
Albert Holguin at 25-Mar-11 21:34pm
   
my 5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Have a look at this[^] nice CP Tip/Trick. TCHAR is well explained there. Smile | :)
  Permalink  
Comments
SAKryukov at 25-Mar-11 15:31pm
   
Seems to be a good reference. These types is a permanent source of confusion. My 5.
--SA
Nuri Ismail at 25-Mar-11 17:41pm
   
Thank you, SA.
Albert Holguin at 25-Mar-11 21:10pm
   
great link!
Albert Holguin at 25-Mar-11 21:12pm
   
to supplement the answer.... a lot of times when you see a name with all caps, as in TCHAR, its an indication of a macro
santosh dhanawade at 26-Mar-11 0:11am
   
Good link
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

TCHAR is defined as char in a non-Unicode project, and as WCHAR (16 bit character) in a Unicode project. This allows the same code to be ported from non-Unicode to Unicode fairly easily.
  Permalink  
Comments
SAKryukov at 25-Mar-11 15:31pm
   
Correct, my 5.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

For the first: TCHAR is not a type themselves - its a placeholder for the character type you use. This can be:
* unicode characters (unsigned short or wchar_t)
* ANSI characters (char).
this depends on your project settings. You can plan your module to support both of them. Therefore you have to generate a project configuration for each. But now what can do TCHAR for you? if you use TCHAR as type for character or string operations you can compile both versions in the same way. The only thing you have to is to include <tchar.h> that maps (#define) the necessary function for you.
i.e.:
* _tcscmp: strcmp or wcscmp
* _tcslen: strlen or wcslen
* and so on.
Regards.
  Permalink  
v3
Comments
SAKryukov at 25-Mar-11 15:33pm
   
Correct, my 5.
--SA
santosh dhanawade at 26-Mar-11 0:12am
   
Qiut interesting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 330
1 Sergey Alexandrovich Kryukov 313
2 George Jonsson 291
3 Prasad Avunoori 155
4 OriginalGriff 149
0 OriginalGriff 4,623
1 CPallini 3,410
2 Sergey Alexandrovich Kryukov 2,929
3 George Jonsson 2,319
4 Gihan Liyanage 2,077


Advertise | Privacy | Mobile
Web02 | 2.8.140905.1 | Last Updated 25 Mar 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100