How to Determine If a String Is UNICODE or ANSI (138142)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q138142 SUMMARY
ANSI strings use one byte per character if they don't contain any DBCS
characters. UNICODE strings use two bytes per character.
There is a built-in OLE API function that allows you determine whether a
string is UNICODE or ANSI. However, you can also use the Len() and LenB()
Visual Basic functions to compare the length of the string in characters
and in bytes, as demonstrated by the step-by-step example in this article.
NOTE: The code sample in this article will work only for those cases where
you are not likely to encounter DBCS characters in ANSI strings.
Modification Type: | Major | Last Reviewed: | 12/9/2003 |
---|
Keywords: | KB138142 |
---|
|