Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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