Notes on Internationalization for the Device Communications Toolkit

  • Work with strings.
  • Recommended reading.

Work with strings

In an international environment, strings in CIMPLICITY software can be multibyte strings. If you want your code to conform to international standards, It is recommended that you do the following when working with strings:

  • Use the TCHAR macros found in TCHAR.H.
  • Declare string buffers as TCHAR[]. Declare string pointers as TCHAR* or LPTSTR.
  • Wrap string and character constants with the _T() macro.
  • Use the _tcs   () functions in place of the str   () functions. For example, use _tcslen() in place of strlen().
  • Be careful when incrementing a pointer through a string. Remember that a logical character may occupy one or two TCHAR units. So replace code that looks like this:

char *cp;

for (cp = string; *cp != '\0'; ++cp)




with code that looks like this:

TCHAR const *cp;

for (cp = string; *cp != _T('\0'); cp = _tcsinc(cp))




  • Avoid using a variable to hold the value of a logical character. Instead, use a pointer to a character in the string. In particular, avoid the _tcsnextc() macro, because the value it returns appears to be incompatible with some of the C runtime library functions.
  • Use the functions _tccpy() and _tccmp() and string pointers instead of the = and == operators on characters.
  • Use GetStringTypeEx() instead of the character classification macros such as _istalpha().
  • Use CharUpper() and CharLower() instead of _toupper() and _tolower().

Recommended Reading

Microsoft has several good papers on writing international code on its Web site. To find documentation on the web site, go to and search for MBCS.

The following book is also available:

Schmitt, David A., Internationalization Programming for Microsoft® Windows®, ISBN 1-57231-956-9