Page 1 of 1

unicode

PostPosted: Jul 11, 2006 @ 9:42pm
by couderta

PostPosted: Jul 12, 2006 @ 7:14am
by InexorableTash
Windows Mobile builds must be Unicode anyway, so if you're building for WM you're already there - you just need to define UNICODE and _UNICODE in the desktop builds.

Otherwise:

Define UNICODE and _UNICODE
#include <tchar.h>
Wrap all string or character literals in TEXT()
Define all chars/strings as TCHAR instead of char

When you need to deal with non-Unicode APIs (e.g. to write to a text file), use WideCharToMultiByte() and MultiByteToWideChar() for conversions.

...and then fix the inevitable compile/runtime issues you see by correcting the assumptions you made (e.g. assuming sizeof(myString[0]) == 1)

Unless you're building for Win9x systems there's really no reason not to use Unicode and thus just use wchar_t and L"foo" everywhere instead of TCHAR and TEXT() but I like things which compile nicely regardless of the options.