I have a webform and an input if you put in Latté and POST it using JSON…
$.ajax({
type: "POST",
url: "http://"+document.domain+"/includes/rpc.php",
data: {method:"add_item",item:item},
dataType: "json",
timeout: 10000,
success:......
item will be the value Latté Latté is posted and the responding JSON is Latt\u00e9 which the browser interprets as Latté. Effectively this script is a WYSIWYG editor so what you type in you get back. Anyhue if I refresh the text is pulled out of mysql and comes out as Latté?. So I am guessing that MYSQL is not the correct collation?
Some more information – the query to edit the DB is
UPDATE menu_items SET description = 'Latté' WHERE item_id = '742'
the JSON reply is
{"description":"Latt\u00e9","id":"#recordsArray_742"}
To be precise, the collation is the way in which the strings are compared and sorted. It has a relationship with the character set, but your problem is an character set problem, not a collation problem.
The first thing that you’ve to know is which character set you’re using. Are you using UTF-8 or LATIN1 or others?
After that I’d try to output the correct header from the PHP script generating the JSON string. For example for UTF-8:
This could already solve your problem, if it doesn’t we have to look deeper on how do you connect to the DB and how you manipulate your data. Let me know in case which MySQL libraries or framework are you using to connect to the db, and post the relevant source code.