Have a web app that displays a list box that gets populated from MySql. I’m getting this in the exception and am not sure what it is referring to as I’m not doing anything with Json.
Message: Encountered invalid character.
Xojo.Data.GenerateJSON%y%x <------------------------------------------------------------------------------What is this referring to?
We are though. Data is sent to the browser as JSON and that implies UTF8. Check to make sure all of the text youre putting into the listbox has an Encoding because data coming out of a database often does not.
At the top of my open I have: SQLExecute(“Set NameS ‘utf8’”)
Doesn’t that do it.
I just changed the statement to: self.SQLExecute(“Set Names ‘utf8_general_ci’”)
That got rid of the exception, but the listbox doesn’t get populates. I output one of the MySql fields to a local log with every iteration of the while loop. The log shows it went through the look, just didn’t populate the listbox.
Here’s the while loop:
[code]While not rs.eof
if lsCompany <> rs.Field(“Company Name”).StringValue then
lbFirst = True
lstProviders.AddRow rs.Field(“Company Name”).StringValue
lsCompany = rs.Field(“Company Name”).StringValue
lstProviders.AddRow( " -----", rs.Field(“Title”).StringValue, rs.Field(“Contact Person”).StringValue, rs.Field(“Email”).StringValue)
Set a breakpoint on the line that assigns lsCompany. If you inspect it, I suspect the encoding will still be Nil. If so, youll have to call DefineEncoding on that.
I typically use a String extension method:
[code]function UTF8(extends s as String) as String
If s.encoding = Encodings.UTF8 then
If s.Encoding is Nil then
Return DefineEncoding(s, Encodings.UTF8)
Return ConvertEncoding(s, Encodings.UTF8)
Maybe its related to:
As far as I remember I got error messages like the one you get.
Just a wild guess
lsCompany is clean “A.O. Smith Corp.”
The Extends didn’t make a difference. Still nothing makes it to the listbox.
Found something, If I remove the field Title it works.
So what could the problenmbe with one field?
The Charcter Set for the field is utf8
and the collation is utf8_general_ci
I tried Changing it to text, changing length from 250 to 200.
No change in behavior.
I tried create table Test1 as Select * from system_manuceu and used the test1 table with same result.