How to convert a ANSI/MB project into a UNICODE

14 05 2013

Most of the time we may need to give multiple language support for our applications. Incase if we need to support Russian or Chinese language means, definitely we have to give Unicode support for our application. So here I would like to share some tips for converting existing ANSI/MultiByte project into Unicode.

If we build our project in Multi-byte character set it will allocate 1 byte for one character. This is enough for representing all English letters. But if we build our project in Unicode character set it will allocate 2 bytes for each letters. It is required for representing Russian and Chinese letters.

Below are some suggestions for converting MBCS to Unicode project

Step 1: Create new configuration from Project Configuration Manager. Give name something like ReleaseUnicode/DebugUnicode.

Step 2: Change Character Set to Unicode from Project Settings.

Unicode

Step 3: Replace all char datatype with TCHAR. This will automatically switch to normal char or wchar_t based on it is compiled as MBCS or Unicode respectively.

Step 4: Add _T as prefix to each string text. eg: _T(“Hello World”)

Step 5: Replace LPSTR and LPCSTR with LPTSTR and LPCTSTR respectively.

Step 6: Replace following win32 APIs with corresponding Generic equivalent for same.

ANSI/MB API Generic API
strstr _tcsstr
strcmp _tcscmp
sprintf_s _stprintf_s
strlen _tcslen
_stricmp _tcscmp
strcpy_s _tcscpy_s
atol _tstol
atoi _tstoi
atof _tstof
strcspn _tcscspn
fopen_s tfopen_s
strtok_s _tcstok_s
strtol _tcstol
strtoul _tcstoul
Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: