dim s as string = rs.Field("AnyFieldname").StringValue
if s.encoding = nil then
if encodings.UTF8.IsValidData(s) then
s = defineEncoding(s, encodings.UTF8)
else
s = defineEncoding(s, Encodings.WindowsLatin1)
end if
end if
ConvertEncoding(Encodings.WindowsLatin1) is normally not useful in Xojo apps which use UTF-8 for anything.
So the WindowsLatin1 is probably converted to UTF-8 anyway on the next string operation.
You’re right, this is a more defensive approach. I’ll check this out. And FYI I am already using everything in UTF8 but I need Latin1 encoded strings for another Software accessing my data (CTI software: http://www.c4b.de). Unfortunately they cannot deal with encodings as far as I see… so I have to adjust my code…