note 108643 modified in function.iconv by danbrown
| From: | danbrown@php.net | Date: | Fri, 15 Jun 2012 16:00:22 +0000 |
| Subject: | note 108643 modified in function.iconv by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-188636@lists.php.net to get a copy of this message | ||
The "//ignore" option doesn't work with recent versions of the iconv
library. So if you're having trouble with that option, you aren't alone.
That means you can't currently use this function to
filter invalid characters. Instead it silently fails and returns an empty string (or you'll
get a notice but only if you have E_NOTICE enabled). This has
been a known bug with a known solution for at least since 2009 years but no one seems to be willing
to fix it (PHP must pass the -c option to iconv). It's still broken as of the latest
release 5.4.3. https://bugs.php.net/bug.php?id=48147 https://bugs.php.net/bug.php?id=52211 https://bugs.php.net/bug.php?id=61484 [UPDATE
15-JUN-2012] Here's a workaround...
ini_set('mbstring.substitute_character', "none");
$text= mb_convert_encoding($text, 'UTF-8',
'UTF-8'); That will strip invalid characters from
UTF-8 strings (so that you can insert it into a database, etc.). Instead of "none"
you can also use the value 32 if you want it to insert spaces in place of the invalid characters.
--was--
The "//ignore" option doesn't work with recent versions of the iconv library. So if
you're having trouble with that option, you aren't alone.
That means you can't currently use this function to filter invalid characters. Instead it
silently fails and returns an empty string (or you'll get a notice but only if you have
E_NOTICE enabled).
This has been a known bug with a known solution for at least since 2009 years but no one seems to be
willing to fix it (PHP must pass the -c option to iconv). It's still broken as of the latest
release 5.4.3.
https://bugs.php.net/bug.php?id=48147
https://bugs.php.net/bug.php?id=52211
https://bugs.php.net/bug.php?id=61484
http://php.net/manual/en/function.iconv.php