note 86409 added to function.htmlentities
| From: | TomWalter at osu1 dot php dot net | Date: | Fri, 17 Oct 2008 02:14:14 +0000 |
| Subject: | note 86409 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145443@lists.php.net to get a copy of this message | ||
Note that as of 5.2.5 it appears that if the input string contains a character that is not valid for
the output encoding you've specified, then this function returns null.
You might expect it to just strip the invalid char, but it doesn't.
You can strip the chars yourself like so:
iconv('utf-8','utf-8',$str);
You can combine that with htmlentities also:
$str = htmlentities(iconv('UTF-8', 'UTF-8//IGNORE', $str, ENT_QUOTES,
'UTF-8');
Should give you a string with htmlentities encoded to utf-8, and any unsupported chars stripped.
----
Server IP: 117.104.160.194
Probable Submitter: 210.9.182.39
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/86409
Del: integrated -- https://master.php.net/note/delete/86409/integrated
Del: useless -- https://master.php.net/note/delete/86409/useless
Del: bad code -- https://master.php.net/note/delete/86409/bad+code
Del: spam -- https://master.php.net/note/delete/86409/spam
Del: non-english -- https://master.php.net/note/delete/86409/non-english
Del: in docs -- https://master.php.net/note/delete/86409/in+docs
Del: other reasons-- https://master.php.net/note/delete/86409
Reject -- https://master.php.net/note/reject/86409
Search -- https://master.php.net/manage/user-notes.php