String operations are another area that simply relied on existing DOS C functions under Windows 3.x. Like the other operations we’ve discussed, Windows 98/95/NT string operations are supplemented by newer API functions, which are compatible with Unicode strings and with international character sets.
NOTE
See Chapter 4 for more information about Unicode, ANSI, and MBCS characters.
These newer API string functions, however, have not superseded the familiar string functions. You should continue to use #include <string.h> for old-style string functions. However, applications using Unicode strings should employ the API string functions rather than relying on the conventional string functions. Of course, applications written using the API string functions remain compatible with both Unicode and ANSI strings.
The following two code fragments contrast conventional and Windows 98/95/NT-supplied string functions.
strupr( szFPath ); // 3.x
if( szFPath[ strlen(szFPath)-1 ] != ‘\\’ )
strcat( szFPath, “\\” );
strcpy( szFName, fileinfo.ff_name );
In most cases, the corresponding 98/95/NT string functions are distinguished by substituting the form lstr__ for the conventional str__. One exception is the CharUpperBuff function, which replaces the conventional strupr function.
CharUpperBuff( szFPath, lstrlen( szFPath ) ); // 98/95/NT
if( szFPath[ lstrlen(szFPath)-1 ] != ‘\\’ )
lstrcat( szFPath, “\\” );
lstrcpy( szFName, lpFileInfo->cFileName );
Again, these two fragments are provided as illustrations of differences that you may or may not need to take into account while converting applications from Windows 3.x to 98/95/NT.
On the other hand, if you are using the MFC CString class and member functions, the CString class members are already Unicode-compatible.