I think I have an encoding problem.
When I fill a listbox with “£”+rowinvoices.Column(“InvoiceItemCost”).StringValue) I get two diamonds with a ? inside them instead of £
Any ideas how to fix this please?
Many thanks in advance.
I think I have an encoding problem.
When I fill a listbox with “£”+rowinvoices.Column(“InvoiceItemCost”).StringValue) I get two diamonds with a ? inside them instead of £
Any ideas how to fix this please?
Many thanks in advance.
If its web, replace the £ for £
The text from string value may not have a text encoding.
Unless you use MBS SQL Plugin for MySQL , you need to take care about this.
So all text from MySQL with Xojos built in MySQL class needs a defineEncoding call.
It’s a desktop application
[quote=468545:@Christian Schmitz]The text from string value may not have a text encoding.
So all text from MySQL with Xojos built in MySQL class needs a defineEncoding call.[/quote]
It’s sqlite not MySQL. the code is adding the contents of a sqlite field to a string., does the string then change encoding to the appended data then? Ie “some string that would normally be fine”+sqlitedb.Column(“somestring”) would change the whole string to the columns encoding?
Strings coming from databases have no encoding. Xojo does not automatically change encoding. You have to defineencoding to UTF-8.
That was what I was asking above.
I have a string that if used by itself displays fine.
If I add the contents of a column TO that string it loses encoding.
Youd think it would be the other way around.
Basically adding in data from a column strips out the encoding.
This is driving me nuts
According to the LR this should work.
"£"+rowinvoices.Column("InvoiceItemCost").StringValue.ConvertEncoding(Encodings.UTF8)
Except it makes no difference…
try the following.
defineEncoding( "£" + rowInvoices.column( "InvoiceItemCost" ).stringValue, encodings.utf8 )
p.s. Are you sure that Brexit doesn’t have anything to do with the change in currency?
[quote=468568:@Rod Pascoe]This is driving me nuts
According to the LR this should work.
"£"+rowinvoices.Column("InvoiceItemCost").StringValue.ConvertEncoding(Encodings.UTF8)
Except it makes no difference…[/quote]
You cant convert to “other” encoding if it has none to start.
You need to DefineEncoding first.
[quote=468570:@Sam Rowlands]try the following.
defineEncoding( "£" + rowInvoices.column( "InvoiceItemCost" ).stringValue, encodings.utf8 )
p.s. Are you sure that Brexit doesn’t have anything to do with the change in currency?[/quote]
You sir are a star. Have 25 bonus internet points.
Probably is Brexit, I’m blaming it for everything
Thank you so much.
I used this extension method to convert strings to UTF8 text.
[code]Public Function ToUTF8Text(Extends s As String) as Text
Dim Result As Text
If s.Encoding = Nil Then
Result = DefineEncoding(s, Encodings.UTF8).ToText
Else
Result = ConvertEncoding(s, Encodings.UTF8).ToText
End If
Return Result
End Function
[/code]
Drop it in a module and you can use
rowInvoices.column( "InvoiceItemCost" ).stringValue.toUTF8Text
Should be easy enough to convert the result to a string.
SQLite with Xojo works fully UTF-8.
Please don’t just do defineEncoding on some text.
Do check if it has no encoding as Wayne suggested.
Actually it was @Greg O’Lone who suggested the check & I thank him again today for that tip.