Created
June 16, 2011 05:42
-
-
Save nicolap/1028735 to your computer and use it in GitHub Desktop.
Conversione dei caratteri accentati o strambi in ASCII
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
$text = '\1234567890\'ì|!"£$%&/()=?^¬¹²³¼½¬{[]}`~è+òàù,.-<_:;>ç°§*é^?`~[]@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ€ÖÄÜöäüß'; | |
function to7bit($text,$from_enc) { | |
$text = mb_convert_encoding($text,'HTML-ENTITIES',$from_enc); | |
$text = preg_replace( | |
array('/ß/','/&(..)lig;/', | |
'/&([aouAOU])uml;/','/&(.)[^;]*;/'), | |
array('ss',"$1","$1".'e',"$1"), | |
$text); | |
return $text; | |
} | |
$textR = to7bit($text, mb_detect_encoding($text, 'auto')); | |
echo PHP_EOL, $textR, PHP_EOL, PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
La funzione to7bit è quella che implementa la traslitterazione, mentre, la funzione form_prep è una funzione di helper del framework CodeIgniter per la pubblicazione dei dati in form lato view.