1
Good afternoon.
My site runs on ISO-8859-1 encoding and when I pull data from an external XML, some characters return as a question mark.
I tried to convert with <?php header("Content-type: text/html; charset=utf-8"); ?>
but all the rest of the site like the top, footer and other areas suffered from the exchange of coding.
I also added utf8_decode() and nothing solved.
Does anyone know any solution to the problem?
An example link to https://api.dino.com.br/v2/news/118219/mundo-do-marketing
<?php
$arquivo = "https://api.dino.com.br/v2/news/$id/mundo-do-marketing";
$info = file_get_contents($arquivo);
$lendo = json_decode($info);
echo '<pre>' . print_r($lendo, true) . '</pre>';
echo $lendo->Item->Summary;
$titulo = utf8_decode($lendo->Item->Title);
$autor = utf8_decode($lendo->Item->Author);
$retranca = utf8_decode($lendo->Item->Summary);
$data = date('d/m/Y', strtotime($lendo->Item->PublishedDate));
$categoria = utf8_decode($lendo->Item->Categories[0]->Name);
$conteudo = utf8_decode($lendo->Item->Body);
if($id == 108988){
redirect(base_url('noticias-corporativas'));
}
else{
?>
<h2><?php echo $titulo; ?></h2>
<p class="retranca-dino"><?php echo $retranca; ?></p>
<p class="autor-dino">Categoria: <span class="autor"><?php echo $categoria; ?></span></p>
<p class="autor-dino">Autor: <span class="autor"><?php echo $autor; ?></span></p>
<span class="data-dino">Data de Publicação: <span style="font-weight: normal;"><?php echo $data; ?></span></span>
<?php
if(empty($lendo->Item->Image->Url)){
echo NULL;
}
else{
$imagem = $lendo->Item->Image->Url;
?>
<div class="imagem-dino">
<img class="imagem" src="<?php echo $imagem; ?>" alt="<?php echo $titulo; ?>" title="<?php echo $titulo; ?>" />
</div>
<?php
}
}
?>
<div class="conteudo-dino"><?php echo $conteudo; ?></div>
<?php
echo br(1);
?>
Att.
have tried
mb_convert_encoding($texto, 'ISO-8859-1', 'UTF-8')
?– deoliveiralucas
deoliveiralucas did not work, keeps returning as interrogation.
– Rafael S. Oiveira
How do you get this external XML data? Put the question there.
– user26552
I updated the question
– Rafael S. Oiveira
One thing I noticed is that the shape of the quotes are different, let me try to explain. Kind of an hour are rounded and another time is normal as on the keyboard, will be that are not registering content with mixed text?
– Rafael S. Oiveira