M
Mike Labosh
I need to determine if a string contains double-byte (unicode) characters.
In SQL, it was easy. Cast it from NVARCHAR to VARCHAR and back again, and
see if it got lossage.
But in VB.NET, all strings are stored as unicode, so I'm not sure what to
do. I'd like to do something like this: [p-code]
Dim s1, s2 As String
s1 = [my db value]
s2 = CType(CType(s1, AnsiString), String)
If s1 = s2 Then
All characters are ANSI ones
Else
Some characters are double byte
End If
What I certainly don't want to do is loop over the characters to see if
AscW(Mid(s1, i, 1)) > 255 because I'm already looping over 100's of
thousands of records and I don't want to have to sniff individual characters
in a batch like this.
--
Peace & happy computing,
Mike Labosh, MCSD
"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
In SQL, it was easy. Cast it from NVARCHAR to VARCHAR and back again, and
see if it got lossage.
But in VB.NET, all strings are stored as unicode, so I'm not sure what to
do. I'd like to do something like this: [p-code]
Dim s1, s2 As String
s1 = [my db value]
s2 = CType(CType(s1, AnsiString), String)
If s1 = s2 Then
All characters are ANSI ones
Else
Some characters are double byte
End If
What I certainly don't want to do is loop over the characters to see if
AscW(Mid(s1, i, 1)) > 255 because I'm already looping over 100's of
thousands of records and I don't want to have to sniff individual characters
in a batch like this.
--
Peace & happy computing,
Mike Labosh, MCSD
"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"