"UTF Decode" tosco


/ Published in: PHP
Save to your folder(s)

Esse singelo trecho foi usado em um código que eu vi para corrigir o encoding de strings...


Copy this code and paste it in your HTML
  1. $pattern = array( 'ã', 'á', 'â', 'Â', 'À', 'Ã<81>', 'Ã', 'Ê', 'È', 'É', 'ê', 'é', 'è', 'Ã<8d>', 'ÃŒ', 'Ĩ', 'ÃŽ', 'í', 'ì', 'î', 'Ä©', 'ô', 'õ', 'ó', 'ò', 'ô', 'Ã"', 'Õ', 'Ã"', 'Ã"', 'û', 'ú', 'Å©', 'ù', 'u', 'Û', 'Ú', 'Ù', 'Ũ', 'ç', 'Ç','°','ª','Í','“' );
  2. $replace = array( 'ã', 'á', 'â', 'Â', 'À', 'Á', 'Ã', 'Ê', 'È', 'É', 'ê', 'é', 'è', 'Í', 'Ì', '&#38;#296;', 'Î', 'í', 'ì', 'î', '&#38;#297;', 'ô', 'õ', 'ó', 'ò', 'ô', 'Ô', 'Õ', 'Ó', 'Ó', 'û', 'ú', '&#38;#361;', 'ù', 'u', 'Û', 'Ú', 'Ù', '&#38;#360;', 'ç', 'Ç','°','ª','Í','"' );
  3. return str_replace( $pattern, $replace, $string );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.