Check String for Unicode Characters ( IsUnicode() )
in .Net All Strings are Unicode
we also know that ASCII Characters range is up-to 255 any thing above 255 will be Unicode so what we will do is we will just check each character value if it is above 255 then there is Unicode Characters
here is function which does that
Public Shared Function IsUnicode(ByVal s As String) As Boolean
Dim items As Char() = s.ToCharArray()
For i As Integer = 0 To items.Length – 1If CUShort(AscW(items(i))) > 255 Then
Return True
End IfNext
Return False
End Function
use it like
if IsUnicode(“لعربي“) then
‘ is unicode
else
‘not unicode
end if
Recent Comments