Skip to content

Instantly share code, notes, and snippets.

@wallacesilva
Created December 7, 2016 21:46
Show Gist options
  • Save wallacesilva/aadaf82efd6066f631c8133bb44afc24 to your computer and use it in GitHub Desktop.
Save wallacesilva/aadaf82efd6066f631c8133bb44afc24 to your computer and use it in GitHub Desktop.
funcao gambiarra em php pra resolver problemas de dados não utf8 e converter corretamente.
<?php
// funcao gambiarra em php pra resolver problemas de dados não utf8 e converter corretamente.
// Fonte: https://berseck.wordpress.com/2010/09/28/transformar-utf-8-para-acentos-iso-com-php/comment-page-1/
function utf8Fix($msg){
$accents = array("á", "à", "â", "ã", "ä", "é", "è", "ê", "ë", "í", "ì", "î", "ï", "ó", "ò", "ô", "õ", "ö", "ú", "ù", "û", "ü", "ç", "Á", "À", "Â", "Ã", "Ä", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ó", "Ò", "Ô", "Õ", "Ö", "Ú", "Ù", "Û", "Ü", "Ç");
$utf8 = array("á","à ","â","ã","ä","é","è","ê","ë","í","ì","î","ï","ó","ò","ô","õ","ö","ú","ù","û","ü","ç","Á","À","Â","Ã","Ä","É","È","Ê","Ë","Í","Ì","Î","Ï","Ó","Ò","Ô","Õ","Ö","Ú","Ù","Û","Ü","Ç");
$fix = str_replace($utf8, $accents, $msg);
return $fix;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment