Skip to content

Instantly share code, notes, and snippets.

@nicolap
Created June 16, 2011 05:42
Show Gist options
  • Save nicolap/1028735 to your computer and use it in GitHub Desktop.
Save nicolap/1028735 to your computer and use it in GitHub Desktop.
Conversione dei caratteri accentati o strambi in ASCII
$text = '\1234567890\'ì|!"£$%&/()=?^¬¹²³¼½¬{[]}`~è+òàù,.-<_:;>ç°§*é^?`~[]@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ€ÖÄÜöäüß';
function to7bit($text,$from_enc) {
$text = mb_convert_encoding($text,'HTML-ENTITIES',$from_enc);
$text = preg_replace(
array('/&szlig;/','/&(..)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;
@nicolap
Copy link
Author

nicolap commented Jun 16, 2011

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment