Unicode Characters and AscB AscW ChrB and ChrW

The Unicode character set was developed to support software internationalization and the consequent need for many more characters than the original ASCII character set could provide. Unicode characters are represented by two bytes and can therefore represent up to 65,536 characters, whereas ANSI's one-byte representation can cope only with 256. Today, both Windows NT and OLE 2.0 are entirely Unicode, and since Version 4, Visual Basic has represented strings in Unicode internally.

Because of the way VB handles strings internally, the operation of certain functions (such as Chr) has changed when compared to VB's early versions. For example, assigning the return value of Chr to a string data type results in a string one byte in length under Windows 95, a non-Unicode system; this is the traditional behavior of Chr. But under Windows NT, a Unicode system, it results in a string two bytes in length. To cope with the extra demands of Unicode, VB4 introduced a number of new functions, including AscB, AscW, ChrB, and ChrW. The "W"-suffixed functions handle the two bytes of Unicode characters. The "B"-suffixed functions work with Byte data, but, like the Asc and Chr functions, handle only the first byte of the byte string passed to them.

Asc, AscB, AscW Functions 131

See Also

Chr, ChrB, ChrW Functions

Was this article helpful?

+1 -2

Post a comment