note 69412 added to function.mb-convert-encoding

From: Date: Tue, 05 Sep 2006 13:46:41 +0000
Subject: note 69412 added to function.mb-convert-encoding
Groups: php.notes 
Request: Send a blank email to php-notes+get-116700@lists.php.net to get a copy of this message
I'd like to share some code to convert latin diacritics to their traditional 7bit representation, like, for example, - à,ç,é,î,... to a,c,e,i,... - ß to ss - ä,Ä,... to ae,Ae,... - ë,... to e,... (mb_convert "7bit" would simply delete any offending characters). I might have missed on your country's typographic conventions--correct me then. <?php /** * @args string $text line of encoded text * string $from_enc (encoding type of $text, e.g. UTF-8, ISO-8859-1) * * @returns 7bit representation */ 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; } ?> Enjoy :-) Johannes ---- Server IP: 212.124.37.9 Probable Submitter: 88.73.214.109 ---- Manual Page -- http://www.php.net/manual/en/function.mb-convert-encoding.php Edit -- https://master.php.net/note/edit/69412 Del: integrated -- https://master.php.net/note/delete/69412/integrated Del: useless -- https://master.php.net/note/delete/69412/useless Del: bad code -- https://master.php.net/note/delete/69412/bad+code Del: spam -- https://master.php.net/note/delete/69412/spam Del: non-english -- https://master.php.net/note/delete/69412/non-english Del: in docs -- https://master.php.net/note/delete/69412/in+docs Del: other reasons-- https://master.php.net/note/delete/69412 Reject -- https://master.php.net/note/reject/69412 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116700) next »