Character Set Considerations
As stated earlier, Windows CE is a Unicode environment. While it supports ASCII functionality to allow the exchange of text files, the native text format is Unicode. The following list provides guidelines for converting ASCII-based code to Unicode:
- Include Tchar.h. It has all the necessary conversions.
- Use the Win32 string functions, rather than the C run-time library equivalents.
- Use TCHAR or LPTSTR for declarations. Declaring character variables as TCHAR allows the code to be compiled as either Unicode or ASCII.
- Use the Text macro for string literals, such as Text("a string"). The Text macro identifies a string as Unicode when the UNICODE compile flag is used or as an ANSI string when Unicode is not defined.
Use the size of (TCHAR) operator to ensure that your code is valid for both Unicode and ASCII. When you increment pointers, remember that an ASCII character is one byte, but that a Unicode character is two bytes.