note 21527 deleted from function.htmlspecialchars by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 12:19:35 +0000 |
| Subject: | note 21527 deleted from function.htmlspecialchars by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197189@lists.php.net to get a copy of this message | ||
Note Submitter: akira dot yoshi at shrine dot de
----
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