JSON Accents Problem on serverside processing

JSON Accents Problem on serverside processing

paulobarrospaulobarros Posts: 1Questions: 0Answers: 0
edited August 2012 in DataTables 1.9
I'm having a problem with the charset on datatables. The JSON returned by the processing script is valid, but I don't know why, sometimes it shows the accents, and sometimes it doesn't.

[code] while ( $aRow = mysql_fetch_array( $rResult ) )
{
$output['aaData'][] = array($aRow['produto_id'],$aRow['produto_ref'],utf8_encode($aRow['produto_nome']));
}


echo json_encode( $output );

[/code]

This is how I'm passing the data from the database to the aaData array, and my JSON is fine as you can see here:
[code]
{"sEcho":1,"iTotalRecords":"266","iTotalDisplayRecords":"266","aaData":[["1","1117365","Bailarina Aer\u00f3bico "],["2","8117112","Bailarina Light Lisa"],["3","35117141","Bailarina Estampada"],["4","52126418","Bata Costa Aberta"],["5","12126477","Bata Dry"],["6","12126501","Bata Dry Longona"],["7","32126480","Bata Manga"],["8","40126304","Bata Pontinho Curta"],["9","40126257","Bata Pontinho Longa"],["10","40126598","Bata Pontinho Manga"]]}
[/code]
But then if I click on the navigation links, the JSON response doesn't show right:
[code]
{"sEcho":1,"iTotalRecords":"266","iTotalDisplayRecords":"266","aaData":[["1","1117365","Bailarina Aer\u00c3\u00b3bico "],["2","8117112","Bailarina Light Lisa"],["3","35117141","Bailarina Estampada"],["4","52126418","Bata Costa Aberta"],["5","12126477","Bata Dry"],["6","12126501","Bata Dry Longona"],["7","32126480","Bata Manga"],["8","40126304","Bata Pontinho Curta"],["9","40126257","Bata Pontinho Longa"],["10","40126598","Bata Pontinho Manga"]]}
[/code]
Sometimes is the inverse, it shows wrong when the page is loaded the first time, but them when I click on the navigation links, it shows the data right. I dont know if you noticed the difference in the two responses:

"Bailarina Aer\u00f3bico " - Response 1
"Bailarina Aer\u00c3\u00b3bico " - Response 2

And when it shows the data the right way, if I search for a word that has an accent, it shows that it has no matches. But if the data is showed wrong, then I can search for the accents and will get a match. Weird.

I hope you can tell me what I'm doing wrong guys. Thank you.
This discussion has been closed.