Euro Symbol Issues

My application was working fine. After a few Xojo crashes and recovers, it now shows (some, not all) of € symbols like this:

[code]Dim mySymb As String
Dim myValue As String

mySymb = “+€”
myValue = “2.5”

myLabel.Text = mySymb + myValue
[/code]

Edit: Desktop Application (Windows) I haven’t tested it on any other environments.

that happens if text encodings go wrong, e.g. your text has UTF-8 content, but it is marked as being Windows ANSI string.

I am doing this

mySymb = mySymb.ConvertEncoding(Encodings.UTF8)

But no changes :frowning:

[quote=136200:@Walter Sander]I am doing this

mySymb = mySymb.ConvertEncoding(Encodings.UTF8)

But no changes :([/quote]

I have noticed that sometimes accents entered in the code do strange things. You may want to do :

mySymb = "+"+&u20AC

@Michel Bujardet thanks, still not working :frowning:

I have noticed it happens mostly when the code is not embedded within an object (Window, Button), for instance if the code is in a Method or Super

[quote=136204:@Walter Sander]@Michel Bujardet thanks, still not working :frowning:

I have noticed it happens mostly when the code is not embedded within an object (Window, Button), for instance if the code is in a Method or Super[/quote]

If even &u20AC does not work, I do not see what to tell you. Your code could be haunted …

I pasted your code an ran it, the € displays fine. Tried it in an event or a separate method. I would not even know where to start with such a simple code to reproduce the issue you describe. Are you positive you are using exactly the code you posted ? No memoryblock or database somewhere by any chance ?

The only way I get the fated is by using a memoryblock that trashes Xojo UTF8 and turns it into crappy bytes :

[code] Dim mySymb As String
Dim myValue As String

mySymb = “+€”
myValue = “2.5”

dim m as MemoryBlock
m = mySymb + myValue

Label1.Text = m.StringValue(0,m.size)[/code]

If you are not using a memoryblock or some other device that can destroy UTF8 and it persists, dump the pesky label and replace it. Could be some kind of corruption. Restart Xojo. If it still does not do, uninstall and reinstall Xojo…

And please, let us know where the ghoulish pest was hiding. Halloween is getting close…

@Michel Bujardet I appreciate your assistance. I am sure it is not a memoryBlock and would have to replace the window and everything else too because if I do a self.title = myLabel.Text the issue is copied to the title.

The workaround by now is assigning the letter directly like this:

Dim myValue As String myValue = "2.5" myLabel.Text = "+€" + myValue

On other projects it works just fine.

Edit: Sorry, this solution I just posted above is not working too

have you tried mySymb = mySymb.DefineEncoding(Encodings.UTF8) ?

Or have you tried to check how mySymb is seen by the program? (break just after the mySymb = “+€” and look at the debugger)

@Antonio Rinaldi Thanks!

Okay the issue was not the symbol, the issue was the number I am actually reading from a TCPSocket connection and Xojo made an assumption for the encoding of the final variable (because I was inputing two different encodings into one variable).

Dim receivedNumber As String = “+€” + somethingIreceivedFromTcpSocket
receivedNumber = receivedNumber .DefineEncoding(Encodings.UTF8)

Solved! So all your answers here are valid. Thanks

[quote=136217:@Walter Sander]@Michel Bujardet I appreciate your assistance. I am sure it is not a memoryBlock and would have to replace the window and everything else too because if I do a self.title = myLabel.Text the issue is copied to the title.

The workaround by now is assigning the letter directly like this:

Dim myValue As String myValue = "2.5" myLabel.Text = "+€" + myValue

On other projects it works just fine.

Edit: Sorry, this solution I just posted above is not working too[/quote]

I do not not understand your issue with “replace the window”. Can’t you simply add a label to the window for test purposes and use the exact code you just posted with it, just to see if the issue persists ?

What about

Msgbox("+€" + myValue)

to see if the problem is within the label, or at the string stage ?

And while you are at it, why don’t you try

self.Title = "+€" + myValue

instead of copying the potentially corrupted content of myLabel.Text to Window.Title ?

I will stop any suggestion, anyway, since I cannot reproduce the issue. Why do I have the impression there must be more code than you care to post ? If you want more assistance, please post your project.

@Michel Bujardet Yes, I did exactly the same tests you suggest. I should have said the number string was actually being obtained via TCPSocket. My bad; had no idea that was causing the problem since the (visual) issue was with the € symbol.

edit: solved the entire project issue with one line of code:

receivedString = receivedString.DefineEncoding(Encodings.UTF8) // receivedString is something I received from TCPSocket

And that is exactly where the problem is :frowning: You did not post the exact code you were using, so it was impossible for anybody to reproduce the bug.

Your undefined string breaks the process of copy to the label text UTF8 encoding. Always use DefineEncoding on anything coming from a database, a TCPSocket or a memoryblock…

If only you had mentioned that earlier…