webListbox and "Unexpected token" errors

hi, this problem was present from realstudio …
i use mysql as database , all table of myDb ares utf8
i put the data in myDb from webAppPage (data entry), by reading data from standard webcontrols like webText or webTextArea…

when i create a recordset and retrive a lot of records from myDb.Mytable and then
put this data in a webGrid, in most cases my webApp crashes and the error stored in log or showed is this :

"JavaScript Error:
Error: Trouble evaluating response: Unexpected token ’ in JSON at position "

“JavaScript Error:
Error: Trouble evaluating response: Unexpected token )”

this error that afflicts webListBox of both platform … older realstudio and latest xojo
this error is not an interceptable error (like … try …catch) and crash the webApp and all clients diconnect from this, not crash o close only one session but entire webapp
i read most conversation that exposes a lot of system to clear string that db return before put this data in a cell of webListBox,
but these tecniques not work fine

there is a secure system to not get into this problem ??

Are you setting the encoding on the strings when you retrieve them? Json expects UTF8.

post open connection to myDb i use this code (that i have find on forum)

dbMy.SQLExecute(“set names utf8 collate utf8_general_ci; set character set utf8”)

then i try to clean special characters from retrieved string with apposite function
but all of this not work fine

can you explain me what is "Are you setting the encoding " ??

When you retrieve data, do something like this…

s = DefineEncoding(rs.field("name").stringvalue, encodings.utf8)

Otherwise what you have is a string of bytes and the framework has no way to know how to interpret the data.

Look in the Language Reference under Encoding for more examples.

ok , i will try

but this tecnique solves all problems of putting string in webListBox , even if the string contains special characters such as accented letters and carriage returns ??’

[quote=294628:@Jury Buono]ok , i will try

but this tecnique solves all problems of putting string in webListBox , even if the string contains special characters such as accented letters and carriage returns ??’[/quote]
It’ll fix the special characters. Carriage returns are already handled by the framework.