1
I want to make it clear that I searched on the forum and in many other places about it, none of them solved my problem, so don’t mark it as duplicate because I believe my problem is specific.
The situation is as follows, I have a system that queries CNPJ and returns the company data, but when it returns the data, the accents return in this mode �
.
Information
The page is obviously on .php
but contains HTML, html is with the meta <meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" />
.
What I tried
ini_set("Content-Type: text/html; charset=",true);
header('Content-Type: text/html; charset=utf-8');
<meta charset="utf-8" />
ini_set( 'default_charset', 'utf-8');
<meta charset="iso-8859-1" />
None worked and the strange thing is that part of PHP shows the accents normally and the whole html shows the normal accents. The same problem is when it will return the results, it is only there that the accents saw �
.
Code is like this
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0" />
<meta http-equiv="content-Language" content="pt-br">
<meta name="google-site-verification" content="Dpev78tlrZLwv3LWGgVXA9_AvLw3JksSJyvYYnBNMvk" />
<title>Barie Toner - Recarga de Toner e Cartuchos, Manutenção de Impressoras em São Bernardo</title>
<meta property="og:locale" content="pt_BR" />
<meta content="Recarga de Toner e Cartuchos em São Bernardo, Manutenção de Impressoras em SBC, São Bernardo, Recarga de Cartuchos e Toners HP, LexMark, Brother, Epson, Brother e Copiadoras. Toners Compatíveis..." name="description" />
<meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Copyright" content="(c) 2016 Barie Toner Recarga de Toner e Cartuchos" />
<script type="text/javascript">
function abrir(URL) {
var width = 466;
var height = 580;
var left = 99;
var top = 99;
window.open(URL, 'janela', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}
</script>
<link rel="shortcut icon" type="image/x-icon" href="/ICON.png" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
<link href='http://fonts.googleapis.com/css?family=Raleway:400,900,800,700,600,500,300,200,100' rel='stylesheet' type='text/css'>
<script src="js/jquery-1.8.0.min.js" type="text/javascript"></script>
<!--[if lt IE 9]>
<script src="js/modernizr.custom.js"></script>
<![endif]-->
<script src="js/jquery.carouFredSel-5.5.0-packed.js" type="text/javascript"></script>
<script src="js/functions.js" type="text/javascript"></script>
<script src="js/topbar.js" type="text/javascript"></script>
</head>
<body>
<!-- shell -->
<div class="shell">
<!-- container -->
<div class="container">
<!-- header -->
<header id="header">
<!-- aparecer no desktop -->
<div class="mobile-hide">
<h1 id="logo"><a href="#">Recarga de Toner e Cartuchos, Manutenção de Impressoras</a></h1></div>
<!-- aparecer no mobile -->
<div class="mobile">
<div class="desktop-hide">
<h1 class="logomobile"><a href="#">Recarga de Toner e Cartuchos, Manutenção de Impressoras</a></h1></div>
</div>
<!-- search -->
<div class="search">
<form action="resultado.php" id="cse-search-box">
<input type="hidden" name="cx" value="001732308738676474369:mki_bote1mm" />
<input type="hidden" name="cof" value="FORID:10" />
<input type="hidden" name="ie" value="utf-8" />
<input "text" name="q" size="31" class="field" value="Pesquise aqui" title="Pesquise aqui" />
<input type="submit" name="sa" class="search-btn" value="" />
<div class="cl"> </div>
</form>
</div>
<!-- end of search -->
<div class="cl"> </div>
</header>
<!-- end of header -->
<!-- navigaation -->
<nav id="navigation">
<a href="#" class="nav-btn">Abrir Menu<span></span></a>
<ul>
<li><a href="index.php">Consultar Endereço</a></li>
<li><a href="cfdw.php">Consultar CEP</a></li>
<li class="active"><a href="ndsa.php">Consultar CNPJ</a></li>
<li><a href="razda.php">Consultar Razão Social</a></li>
<li><a href="index.html">Sair</a></li>
</ul>
<div class="cl"> </div>
</nav>
<!-- end of navigation -->
<!-- main -->
<div class="main">
<div class="featured">
<?php
ini_set( 'default_charset', 'utf-8');
require('funcoes.php');
$cnpj = $_POST['CNPJ'];
$captcha = $_POST['CAPTCHA'];
// pega html resposta da receita
$getHtmlCNPJ = getHtmlCNPJ($cnpj, $captcha);
if($getHtmlCNPJ)
{
// volova os dados em um array
$campos = parseHtmlCNPJ($getHtmlCNPJ);
echo "mostra os resultados";
}
?>
</div>
<!-- end of main -->
<div class="cl"> </div>
<!-- footer -->
<div id="footer">
<div class="footer-nav">
<ul>
<li class="active"><a href="home.html">Ínicio</a></li>
<li><a href="sobre.html">Sobre</a></li>
<li><a href="servicos.html">Serviços</a></li>
<li><a href="area-de-cobertura.html">Cobertura</a></li>
<li><a href="contato.html">Contato</a></li>
</br>
<li>[email protected] | [email protected] | (11) 2922-5072</a>
</li>
</ul>
<div class="cl"> </div>
</div>
<p class="copy">
<a href="skype:[email protected]?chat"><img src="css/images/skype.png"></a>
<a href="javascript:abrir('https://tawk.to/c6fe2e15a65eee77616fd7836828c5b00f470407/popout/default/?$_tawk_popout=true&$_tawk_sk=56dd81082445fbd60e8104b7&$_tawk_tk=d9297f446fdd74f9eaf318bc1c43190e&v=458');"><img src="css/images/suporte.png"></a>
<a href="mailto:[email protected]"><img src="css/images/email.png"></a>
<a href="contato.html"><img src="css/images/telefone.png"></a>
<div class="cl"> </div>
</div>
<!-- end of footer -->
</div>
<!-- end of container -->
</div>
<!-- end of shell -->
</div>
<!-- end of wrapper -->
</div>
</body>
</html>
I don’t know what else to do, everything I do always comes back in the same mistake.
Have you tried using utf8_decode($string); ? ?
– chavesfop
This I have not tried, I will try and warn you and I have tested all the encoding allowed, I use the Sublime Text and its variation is great, but even so, no results.
– João Victor Gomes Moreira
Try using utf8_encode ($content) or utf8_decode ($content)
– Fleuquer Lima
@Fleuquerlima it works with normal echo?
– João Victor Gomes Moreira
You have looked at this http://answall.com/a/43205/91?
– rray
yes, just use it like this: echo utf8_encode($content);
– Fleuquer Lima
Yes @rray, but it didn’t help me at all unfortunately.
– João Victor Gomes Moreira
I noticed that in your html you have both Charsets, leave only one, I suggest utf-8
– rray
Which charset, collation you are using in the bank? If the seat support does not support the accent, the error comes from the.
– Guilherme Lautert
Thank you all, the problem has been solved using
utf8_encode($conteudo);
, very simple alias, not even needed to have changed so much haha– João Victor Gomes Moreira