note 83168 added to function.htmlentities
| From: | eric at tillandsia dot nl | Date: | Tue, 13 May 2008 19:06:23 +0000 |
| Subject: | note 83168 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139341@lists.php.net to get a copy of this message | ||
I don't know, but I get a lott of warnings about unknown html entities when I use the function:
htmlentities($str,HTML_ENTITIES,'UTF-8')
The function below works fine for me, just a replacement by a decimal coding.
A str_replace for each possible latin character in a string as in an earlier example using a hash
table is slowing down the script, because you go through the string for each latin character again.
In the example below, you will go through it only once.
function parseXMLcoding($string)
{
if ( strlen($string) == 0 )
return $string;
$string = preg_split("//", $string, -1, PREG_SPLIT_NO_EMPTY);
for ( $i = 0; $i < count($string); $i++ )
{
$dec = ord($string[$i]);
if ( $dec > 127 )
$string[$i] = '&#' . $dec . ';';
}
return implode('',$string);
}
----
Server IP: 83.137.20.135
Probable Submitter: 82.171.91.154
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/83168
Del: integrated -- https://master.php.net/note/delete/83168/integrated
Del: useless -- https://master.php.net/note/delete/83168/useless
Del: bad code -- https://master.php.net/note/delete/83168/bad+code
Del: spam -- https://master.php.net/note/delete/83168/spam
Del: non-english -- https://master.php.net/note/delete/83168/non-english
Del: in docs -- https://master.php.net/note/delete/83168/in+docs
Del: other reasons-- https://master.php.net/note/delete/83168
Reject -- https://master.php.net/note/reject/83168
Search -- https://master.php.net/manage/user-notes.php