How to Determine If a String Is UNICODE or ANSI
Article ID: 138142
Article Last Modified on 12/9/2003
APPLIES TO
- Microsoft Visual Basic 4.0 Standard Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 16-bit Enterprise Edition
- Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
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.
Additional query words: 4.00 vb4win vb4all
Keywords: KB138142