Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unicode

Status
Not open for further replies.

ceodav

Programmer
Feb 21, 2003
106
IT
hi,
i started to convert an application toward a multilanguage application by using string tables.

i insert some different languages and it works fine, but i don't know how to deal the char variables inside the code.

1) is it right to change all the char definistions into TCHAR?
2) is it right to change all the function sprintf, strcat, strtok, strcpy, etc into _stprintf, _tcscat, _tcstok, etc ...?
3) what about all the string composed, i have to write the _T("") before any string in the code?

like

_stprintf( pcFilenameTmp, "%s_%d", szNameFile, k );

i must write

_stprintf( pcFilenameTmp, _T("%s_%d"), szNameFile, k );


4) other things i don't know?


thanks

Davide
 
The one you really have to watch out for is sizeof. Many routines require the number of elements in the array. Since it used to be chars, you'd do something like
Code:
char str[200];
getstring (str, sizeof (str));
When converting to Unicode, this has to be changed to
Code:
TCHAR str[200];
getstring (str, sizeof (str)/sizeof (str[0]));
Also don't forget to set the Unicode flag in compilation. If you get linkage errors, check the libraries it is trying to link. They should end with U or UD. If they don't then it is trying to link MBCS libraries.

Will your code be multi-platform? If it will, Unicode is not 16 bits on all platforms. On *nix, it is 32 bits.

Some fonts are DBCS i.e. neither MBCS nor Unicode. Make sure you do not pick one of those as a base font for your dialogs. Some of the Japanese/Chinese fonts are DBCS.
 
thanks,

but sizeof (str)/sizeof (str[0]) it's only for char variable right?

or even for structure which contains TCHAR?
during fwrite for example

Davide
 
sizeof(x)/sizeof(x[0]) will return the size of an array of any type of data.
 
fwrite needs the number of bytes so in that case you need just plain sizeof.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top