note 47149 added to function.htmlspecialchars

From: Date: Thu, 04 Nov 2004 14:46:55 +0000
Subject: note 47149 added to function.htmlspecialchars
Groups: php.notes 
Request: Send a blank email to php-notes+get-79610@lists.php.net to get a copy of this message
it seems it does NOT replace &#8364; (euro sign) with &euro; (also during posting here it gets replaced with &#8364; ...) i use this general translation function: <?php /** * @return string the translated string * @param string $str stirng to translate * @param bool $br replace line breaks with '<br />'? (default: FALSE); * @param bool $nbsp replace spaces with '&nbsp'? (default: FALSE); * @desc returns html-translated string (replaces special chars, umlauts, euro and optionally line breaks and sapces */ public static function translate($str, $br = FALSE, $nbsp = FALSE) { $r = htmlentities($str); // euro hack // make sure you have the real euro sign here (it gets lost during posting it seems) $r = str_replace('&#8364;', '&euro;', $r); // has to go first because of space in <br /> if($nbsp) $r = str_replace(' ', '&nbsp;', $r); if($br) $r = str_replace("\n", '<br />', $r); return $r; } ?> maybe somebody else here has a use for it too.... ---- Manual Page -- http://www.php.net/manual/en/function.htmlspecialchars.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47149 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47149&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47149&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47149&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47149&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47149&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47149&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47149&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#79610) next »