ToText deprecated is a string property of a Class represented by “u”

Porting to the new API, the old code was:

elseif = "Blücher" then

Xojo does not accept changing it to:

elseif = "Blücher" then

If comparing the strings directly:

elseif = "Blücher" then

the strings don’t match. This issue occurs after saving/loading from an SQLite database. Using toText again and ignoring the deprecated warning makes it work. This is likely an encoding conflict with the “ü” character probably…

Perhaps not surprising as is already a String.

How is the value of set? What encoding shows up if you examine in the debugger?


Have you compared the bytes in your string with the bytes in, by eye? In the debugger?

One might be:


the other might be:


so, two bytes (c3 bc) vs. three bytes (75 cc 88).

(Assuming this is what is meant by combining).

But, what does ToText that make this work? = "Blûcher" // no work =  "Blûcher"  // works

Text is not the same as String. The compiler probably converts your “Blücher” to Text automatically.

Anyway - have you compared them in the debugger?

the debugger shows the name correctly

I suggested to you to compare the bytes.

But as I suspected, the bytes involved are 75 cc 88. These are the bytes from the database. Which will not compare to c3 bc.

Anyone know how to force this to work?

Basically your problem seems to be that the data in the database uses non-composed characters, whereas Xojo is assuming composed characters.

The ü is not composed, in the database - it’s a simple u followed by a composing umlaut (so, two code points, 3 bytes), which will appear the same on-screen as the single code point ü (two bytes). How did the data get into the database?

This may be your answer:

If I display the, for example:

mylabel.text =
it is showed “Blücher” ok, is when comparing that it not works

var  source as string  = "Blücher"
if = source then
end if

in the debbuger
Source shows in Text as “Blücher”
In Binary as show in Text as “Blücher”
but in binary

Right, that’s exactly what Tim has been explaining: those two strings appear the same when printed to the screen, but the underlying bytes are different, and thus the string compare function isn’t behaving as expected.

Go follow that link that I posted and download the Unicode module. Normalize both of your strings and then compare them; you should find that they compare properly.

Honestly I think this is a flaw in how strings are compared, whether that’s in the Unicode specification; the OS’s implementation; or Xojo’s internal implementation. Decomposed characters should equate to their composed representations. I don’t know why it is done this way.

Where is the Unicode module?, please.

May it be considered a bug?
Made the following test::

var enc as TextEncoding =
var  source as string  = "Blücher"
var enc2 as TextEncoding = source.Encoding

source = source.DefineEncoding(enc)

if = source then
end if

enc and enc2 show the same on the debbuger

Pasted Graphic

But the string comparetion fails

The STRING data type has never implemented all of the Unicode rules.

You could try the STRING Compare function to see if that helps but you may find that you need to log an enhancement request.

FYI. The TEXT data type should compare them correctly but that data type is no longer recommended.

1 Like

From the documentation:

This works

elseif"Blücher") = 0 then
1 Like