note 57613 modified in function.html-entity-decode by danbrown
| From: | danbrown@php.net | Date: | Tue, 10 Jan 2012 20:14:01 +0000 |
| Subject: | note 57613 modified in function.html-entity-decode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185543@lists.php.net to get a copy of this message | ||
If you want to decode NCRs to utf-8 use this function instead of chr().
<?php
function utf8_chr($code)
{
if($code<128) return chr($code);
else if($code<2048) return chr(($code>>6)+192).chr(($code&63)+128);
else if($code<65536) return
chr(($code>>12)+224).chr((($code>>6)&63)+128).chr(($code&63)+128);
else if($code<2097152) return chr($code>>18+240).chr((($code>>12)&63)+128)
.chr(($code>>6)&63+128).chr($code&63+128));
}
?>
--was--
If you want to decode NCRs to utf-8 use this function instead of chr().
function utf8_chr($code)
{
if($code<128) return chr($code);
else if($code<2048) return chr(($code>>6)+192).chr(($code&63)+128);
else if($code<65536) return
chr(($code>>12)+224).chr((($code>>6)&63)+128).chr(($code&63)+128);
else if($code<2097152) return chr($code>>18+240).chr((($code>>12)&63)+128)
.chr(($code>>6)&63+128).chr($code&63+128));
}
http://php.net/manual/en/function.html-entity-decode.php