note 93421 modified in function.strtr by danbrown
| From: | danbrown@php.net | Date: | Wed, 09 Sep 2009 14:05:44 +0000 |
| Subject: | note 93421 modified in function.strtr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160349@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:
<?php
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
--was--
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
http://php.net/manual/en/function.strtr.php