note 93421 added to function.strtr

From: Date: Wed, 09 Sep 2009 14:02:58 +0000
Subject: note 93421 added to function.strtr
Groups: php.notes 
Request: Send a blank email to php-notes+get-160348@lists.php.net to get a copy of this message
Hi all, as u probably know the is some truoble with the (for example) hungarian special characters. If I used the htmlentities() function, the simple chars had benn converted to the basic format, for example: & aacute;. However this was very simple, some cases it needs more transformation. As I would like to use the correct caracters even in php, html, js, and more, a wrote this short code to solve this issue: function charcode ($text) { $text = htmlentities($text); //to convert the simple spec chars $search = array("& otilde;","&O tilde;","& ucirc;","&U circ;"); $replace = array("& #337;","& #336;","& #369;","& #368;"); $text = str_replace($search, $replace, $text); return $text; } Now I am able to display any spec chars in any browser with any character encoding set. Hope U will find this helpful. Vyktor ---- Server IP: 92.43.200.200 Probable Submitter: 217.150.128.89 ---- Manual Page -- http://www.php.net/manual/en/function.strtr.php Edit -- https://master.php.net/note/edit/93421 Del: integrated -- https://master.php.net/note/delete/93421/integrated Del: useless -- https://master.php.net/note/delete/93421/useless Del: bad code -- https://master.php.net/note/delete/93421/bad+code Del: spam -- https://master.php.net/note/delete/93421/spam Del: non-english -- https://master.php.net/note/delete/93421/non-english Del: in docs -- https://master.php.net/note/delete/93421/in+docs Del: other reasons-- https://master.php.net/note/delete/93421 Reject -- https://master.php.net/note/reject/93421 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160348) next »