Notes on Internationalization for the External Alarm State Management API
- Work with strings.
- Recommended reading.
Work with strings
This API is written for the international environment. 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 asTCHAR*
orLPTSTR
. - Wrap string and character constants with the
_T()
macro. - Use the
_tcs...()
functions in place of thestr...()
functions. For example, use_tcslen()
in place ofstrlen()
. - 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()
andCharLower()
instead of_toupper()
and _tolower().
Recommended Reading
Microsoft has several good papers on writing international code on its Developer Network DVD and its web site. To find documentation on the web site, go to http://msdn.microsoft.com/default.asp and search for MBBCS.
For documentation on globalization, go to http://www.microsoft.com/globaldev/.
The following book is also available:
- Schmitt, David A., Internationalization Programming for Microsoft® Windows®, ISBN 1-57231-956-9
For more information about this book, go to http://mspress.microsoft.com/books/2323.htm.