Charset issue

Charset issue

javierjavier Posts: 2Questions: 0Answers: 0
edited June 2011 in DataTables 1.8
I recently start to use Data Tables 1.8 within a big information system of an Italian University.

The problem is: the displayed table contains invalid characters, for example the char "à" is display as "�". So it's clear that it is a charset issue.

I am using a MySql database (charset: iso-8859-1). The HTML file has the same charset. The tag make no difference. The server processing PHP file does not use the json_encode() function in the "output phase" because of not suitable for iso-8859-1 charset. Instead of json_encode() function, the server processing PHP file uses the solution found in examples/server_side/scripts/post.php. So all files and all MySql tables use the iso-8859-1 charset.
But the dataType valuee is still "json":
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "server_processing_post.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
} );
Someone knows if there is a possibility to use Data Tables 1.8 in an iso-8859-1 environment? Thank you very much in anticipation.
In any case compliments for this wonderful and poweful plug-in.
Xavier
NB: I am using jQuery vers. 1.5.2 and Data Tables vers. 1.8.0

Replies

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Since you are using server-side processing you might also need to set the character set of the return from server_pocessing_post.php. Something like:

    [code]
    header("Content-Type: text/json; charset=ISO-8859-1");
    [/code]

    DataTables doesn't to character set conversion so it should just pass it straight through to the page - it's just a case of making sure all parts in using ISO-8859-1.

    Regards,
    Allan
  • javierjavier Posts: 2Questions: 0Answers: 0
    Allan,
    I insert the header in the file and now everything is OK.
    Thank you very much for your time, specially on Sunday, and for your very quick answer.
    I will continue to go on with Data Tables because of we want to substitute our old PHP/MySql grid sub-system with Data Tables.
    Kind reards,
    Xavier
  • MarkoAntonjoMarkoAntonjo Posts: 1Questions: 0Answers: 0
    Hi Allan / Javier,

    I have one doubt: where does this header should be inserted to correct invalid characters?
This discussion has been closed.