I need code for removing all unicode characters in a vb6 string.
Need code for removing all unicode characters in vb6
2k views Asked by Narayana At
3
There are 3 answers
0
On
StrConv is the command for converting strings.
StrConv Function
Returns a Variant (String) converted as specified.
Syntax
StrConv(string, conversion, LCID)
The StrConv function syntax has these named arguments:
Part Description
string Required. String expression to be converted.
conversion Required. Integer. The sum of values specifying the type of conversion to perform. `128` is Unicode to local code page (or whatever the optional LCID is)
LCID Optional. The LocaleID, if different than the system LocaleID. (The system LocaleID is the default.)
If this is UTF-16 text (as normal VB6 String values all are) and you can ignore the issue of surrogate pairs, then this is fairly quick and reasonably concise:
This has the workaround for the unfortunate choice VB6 had to make in returning a signed 16-bit integer from the
AscW()
function. It should have been a Long for symmatry withChrW$()
but it is what it is.It should beat the pants off any regular expression library in clarity, maintainability, and performance. If better performance is required for truly massive amounts of text then SAFEARRAY or CopyMemory stunts could be used.