Hi guys !
got a little problem with text and strings
in my case, i have data coming from text and i need to use it / compare it with a string
case one :
Dim T as text = “bla bla” a text from parameter … normaly utf8
Dim S as string = “bla bla”
if T = S then …
it doesn’t match
i tried to convect both of them to TextEncoding.UTF8 … same problem
any idea ?
heh strings and texts handle things differently (personally I think text gets it right)
note how they compare these two bits of UTF-8 data which on screen both show as one “character” and should compare as “the same” since they basically are the same “characters” in them
Dim s1 As String =&u00E8
Dim s2 As String = &u0065 + &U0300
If s1.LenB <> s2.LenB Then
system.debuglog "s1.LenB <> s2.LenB"
End If
If s1.Len <> s2.Len Then
system.debuglog "s1.Len <> s2.Len"
End If
If s1 <> s2 Then
system.debuglog "s1 <> s2"
End If
Dim t1 As Text = &u00E8
Dim t2 As Text = &u0065 + &U0300
Dim te As Xojo.Core.TextEncoding = Xojo.Core.TextEncoding.UTF8
If te.ConvertTextToData( t1, False ).Size <> te.ConvertTextToData( t2, False ).Size Then
system.debuglog "t1.data <> t2.data" // not an exact replica of lenb but close enough for this
End If
If t1.Length <> t2.Length Then
system.debuglog "t1.Length <> t2.length"
End If
If t1 <> t2 Then
system.debuglog "t1 <> t2"
End If
Markus : it’s a little bit more complicated
Norman : i think convert to data could help, but i need to clean some “extra” character from text… it was more easy when i used string…
i’m sending data to usb port and since i moved on Text, i got a lot to deal with :-/
fundamentally way down deep text is still just “runs of bytes” - all data in a computer is
Yeah… but few bytes are not welcome in simple ascii message in usb/bluetooth …