Utf 8 vs ANSI

Utf 8 vs ANSI

ibaitxuibaitxu Posts: 2Questions: 0Answers: 0
edited September 2011 in General
I´m using the "csvtotable" jquery script to render a table from a csv file, and then, I apply datatable. The problem is that the csv is encoded in ANSI (don´t ask me why, but is mandatory) and datatables rendered the table wrong, with strange symbols.
I attempted changing datables and csvtotable codification, but the script failure. If someone can help me please...thanks
I attach part of the code:
[code]







$(function() {
$.get('bbdd.csv', function(data) {
$('#CSVSource').html('' + data + '');
});

$('#CSVTable2').CSVToTable('bbdd.csv' , {separator: ";", loadingImage: 'images/loading.gif', startLine: 1, headers: ['Marca', 'Producto', 'Contacto', 'Teléfono 1', 'Teléfono 2','Email','Página web','Dirección']}).bind("loadComplete",function() {

$('#processingDiv').show();
var oTable = $('#CSVTable2').find('TABLE').dataTable( {
"aoColumns": [
{ "sWidth": "200px" },
{ "sWidth": "600px" },
{ "sWidth": "200px" },
{ "sWidth": "250px" },
{ "sWidth": "400px" },
{ "sWidth": "200px" },
{ "sWidth": "200px" },
{ "sWidth": "1600px"} ,],
"bJQueryUI": true,
"aaSorting":[[1,'asc']],
"sScrollX": "100%",
"sScrollXInner": "140%",
"bScrollCollapse": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 8,
"oLanguage": {
"sLengthMenu": 'Mostrar '+
'8'+
'16'+
'22'+
'28'+
'34'+
'Todas'+
' entradas'
},
"fnInitComplete": function() { $('#processingDiv').hide();
}
} );
new FixedColumns( oTable );
} );
} );

[/code]

Replies

  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    All your Javascript is flagged as charset="utf-8", so that isn't going to help! I'd suggest changing that and making sure the encoding of the page also matches. DataTables doesn't do any character conversion itself. An alternative method would be to use iconv (or whatever) to convert your CSV files to UTF8.

    Allan
  • ibaitxuibaitxu Posts: 2Questions: 0Answers: 0
    edited September 2011
    This last alternative is what I´m looking for, but I´m not able to convert the csv to utf 8.
    I´m not able to use iconv with my code.
This discussion has been closed.