UniversalCharacterDetectionMBS
returns a string version of the charset it detected, is there an existing good way to get a TextEncoding
object from MBS based on this, or should I just loop through all the TextEncoding
InternetName
s and compare them?
For what it’s worth in the future, this works.
[code]Function GetEncoding(sInput as String) As TextEncoding
dim oEncodingDetection as new UniversalCharacterDetectionMBS(UniversalCharacterDetectionMBS.FilterAll)
oEncodingDetection.AddData(sInput)
oEncodingDetection.Finish
dim sEncodingName as String = oEncodingDetection.LastCharSet
dim oEncoding as TextEncoding
dim iEncCount as Integer = Encodings.Count - 1
for i as Integer = 0 to iEncCount
if sEncodingName = Encodings.Item(i).InternetNameMBS then
oEncoding = Encodings.Item(i)
exit
end
next
return oEncoding
End Function
[/code]
I do this…
[code]Function GetEncoding(sInput as String) As TextEncoding
Dim oEncodingDetection As New UniversalCharacterDetectionMBS(UniversalCharacterDetectionMBS.FilterAll)
oEncodingDetection.AddData(sInput)
oEncodingDetection.Finish
Return GetInternetTextEncoding(oEncodingDetection.LastCharSet)
End Function[/code]
…but after posting I just noticed that GetInternetTextEncoding is OSX only for some reason.
Strange.