Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Dogue

Datatable com erro no charset

Recommended Posts

Estou com um problema na minha datatable com relação a caracteres apresentados, já corrigi este problema no Mysql (Agrupamento (Collation) para UTF-8) também coloquei o charset correto no cabeçalho do HTML, porém mesmo assim continua apresentando caracteres incorretos. Alguém tem alguma expêriencia com esse problema.

A1_zpslhahfpwj.png

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Talvez o dado tenha se perdido na conversão da tabela.

 

Insira uma nova linha no banco, agora que o charset já esta alterado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Okay, eliminamos uma possibilidade.

 

Faça o teu php devolver com header utf-8 o documento.

 

header('Content-Type: text/html; charset=utf-8');
como vc está fazendo esse JSON ?

está entregando ele com header utf8 também ?

 

qual o charset default do servidor ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

sim e Json conforme abaixo, tinha colocado o cabeçalho header ('Content-type: text/html; charset=UTF-8');

function countRec($fname,$tname,$where) {
$sql = "SELECT count($fname) FROM $tname $where";
$result = runSQL($sql);
while ($row = mysql_fetch_array($result)) {
return $row[0];
}
}
$page = $_POST['page'];
$rp = $_POST['rp'];
$sortname = $_POST['sortname'];
$sortorder = $_POST['sortorder'];

if (!$sortname) $sortname = 'pagina_atual';
if (!$sortorder) $sortorder = 'nome_componente';
        if($_POST['query']!=''){
            $where = "WHERE `".$_POST['qtype']."` LIKE '%".$_POST['query']."%' ";
        } else {
            $where ='';
        }
        if($_POST['letter_pressed']!=''){
            $where = "WHERE `".$_POST['qtype']."` LIKE '".$_POST['letter_pressed']."%' ";    
        }
        if($_POST['letter_pressed']=='#'){
            $where = "WHERE `".$_POST['qtype']."` REGEXP '[[:digit:]]' ";
        }
$sort = "ORDER BY $sortname $sortorder";

if (!$page) $page = 1;
if (!$rp) $rp = 10;

$start = (($page-1) * $rp);

$limit = "LIMIT $start, $rp";

$sql = "SELECT id,pagina_atual,pagina_parametrizacao,nome_pagina,componente,nome_componente,descricao FROM paginas $where $sort $limit";
$result = runSQL($sql);

$total = countRec('pagina_atual','paginas',$where);

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );
header("Pragma: no-cache" );
header("Content-type: text/x-json ");
header ('Content-type: text/html; charset=UTF-8');

$json = "";
$json .= "{\n";
$json .= "page: $page,\n";
$json .= "total: $total,\n";
$json .= "rows: [";
$rc = false;

while ($row = mysql_fetch_array($result)) {
if ($rc) $json .= ",";
$json .= "\n{";
$json .= "id:'".$row['id']."',";
$json .= "cell:['".$row['id']."','".$row['pagina_atual']."'";
$json .= ",'".addslashes($row['pagina_parametrizacao'])."'";
$json .= ",'".addslashes($row['nome_pagina'])."'";
$json .= ",'".addslashes($row['componente'])."'";
$json .= ",'".addslashes($row['nome_componente'])."'";
$json .= ",'".addslashes($row['descricao'])."']";
$json .= "}";
$rc = true;
}
$json .= "]\n";
$json .= "}";
echo $json;
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não cara, json não é text/html é application/json

 

Essa forma de vc formar o json pode ser o problema.

Não concatene uma string json na mão.

 

 

Faça um array e deixe o trabalho de converter (inclusive os acentos) para a função json_encode()

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.