note 21527 added to function.htmlspecialchars
| From: | akira dot yoshi at shrine dot de | Date: | Thu, 16 May 2002 01:15:05 +0000 |
| Subject: | note 21527 added to function.htmlspecialchars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30698@lists.php.net to get a copy of this message | ||
If you need to htmlspecialchars a jis string, here's a function that does:
function htmlspecialchars_jis($text) {
$ret="";
if ($text=="") return "";
$esc=chr(27);
$text=$esc."$B".$esc."$B".$text;
$text=str_replace($esc."(B", $esc."$B", $text);
$trans=explode($esc."$B", $text);
$enc=0;
while (list (, $val) = each ($trans)) {
if ($enc==0) {
$val.="";
if ($val!="") $ret.=htmlspecialchars($val);
$enc=1;
} else {
$val.="";
if ($val!="") $ret.=$esc."$B".$val.$esc."(B";
$enc=0;
};
}
return $ret;
};
BTW: I'm very(!) sure that JIS is iso-2022-jp, not iso-2002-jp
--
http://www.php.net/manual/en/function.htmlspecialchars.php
http://master.php.net/manage/user-notes.php?action=edit+21527
http://master.php.net/manage/user-notes.php?action=delete+21527
http://master.php.net/manage/user-notes.php?action=reject+21527