Created
December 7, 2016 21:46
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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