The information in this article applies to:
SUMMARYString operations in systems that use a Double-Byte Character Set (DBCS) are slightly different from a single-byte character system. This article provides guidelines to reduce the work necessary to port an application written for a single-byte system to a DBCS system. MORE INFORMATION
In a double-byte character set, some characters require two bytes,
while some require only one byte. The language driver can distinguish
between these two types of characters by designating some characters
as "lead bytes." A lead byte will be followed by another byte (a "tail
byte") to create a Double-Byte Character (DBC). The set of lead bytes
is different for each language. Lead bytes are always guaranteed to be
extended characters; no 7-bit ASCII characters can be lead bytes. The
tail byte may be any byte except a NULL byte. The end of a string is
always defined as the first NULL byte in the string. Lead bytes are
legal tail bytes; the only way to tell if a byte is acting as a lead
byte is from the context.
To make the code easier to read, an application could define macros
for the AnsiNext() and AnsiPrev() functions if DBCS is not defined:
With these definitions in place, all of the code can be written for
DBCS. Note that the AnsiNext() function will not go past the end of a string and the AnsiPrev() function will not go past the beginning of a string, while the macros will. In addition, because the "y" parameter
in the AnsiPrev() macro is ignored, some code will give different
results when compiled with and without DBCS defined. The following
code is an example of this phenomenon:
The following code demonstrates how to find the offset of the filename
in a full path name:
Note that ':' and '\\' are guaranteed not to be lead bytes. The search
started from the beginning of the string rather than the end to avoid
using the AnsiPrev() function.
The following code demonstrates a string copy into a limited size buffer. Note that it ensures that the string does not end with a lead byte.
Additional query words: 3.00 3.10
Keywords : kb16bitonly kbSDKPlatform |
Last Reviewed: June 8, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |