Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys,

I am converting my project( basically in ascii) to unicode. I need to change all literal strings, char datatypes and functions that deals with strings.

Using TChar.h, I converted CHAR to TCHAR.How about Char * ????

I have many functions where Char * is passed as argument,with which datatype I should replace this to support unicode.

Is it CString??

Please help.

Regards,
Joy
Posted
Updated 18-Jul-13 19:39pm
v2

1 solution

You only need tchar.h and the TCHAR type if you want to produce both ASCII and Unicode versions of your code. If you do it this way then you should use the following types:
C++
TCHAR    character;           // a single character
TCHAR*   character_array;     // an array of characters, aka string
PTCHAR   character_array;     // same as TCHAR*
PTSTR    character_string;    // same as PTCHAR
PCTSTR   constant_string = _T("A constant string"); // all string literals should be coded thus.

The compiler will then generate the correct types and literals based on the setting of the UNICODE define in your project General settings.

If you are converting to Unicode only, then you can use the above types or redefine to all wide characters and use:
C++
WCHAR    character;           // a single character
WCHAR*   character_array;     // an array of characters, aka string
PWCHAR   character_array;     // same as WCHAR*
PWSTR    character_string;    // same as PWCHAR
PCWSTR   constant_string = L"A constant string"; // all string literals should be coded thus.


If your program uses MFC or WTL then you could use CString as an alternative.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900