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 multi-byte strings. If you want your code to conform to international standards, GE Fanuc recommends 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() with string pointers instead of using 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 Developer Network CD 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
About the Alarm Interested Process API. |