note 109796 deleted from function.iconv by danbrown
| From: | danbrown@php.net | Date: | Fri, 31 Aug 2012 15:47:19 +0000 |
| Subject: | note 109796 deleted from function.iconv by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190333@lists.php.net to get a copy of this message | ||
Note Submitter: nate
----
To comment on php's iconv() //IGNORE option not working, that's not quite true. The
//IGNORE option is not designed to handle invalid byte sequences in the input string. Rather, while
operating on a string that is valid in the "from" charset, the //IGNORE option will simply
discard characters that cannot be represented by an approximate sequence in the "to"
charset.
The //IGNORE option does not let you get away with passing garbage in the input - the string you
pass must be valid when looked at through the "to" charset. iconv itself does have a
separate "-c" option on the command-line which enables an option to skip/remove invalid
byte sequences in the input string. This is entirely separate from the purpose of the //IGNORE
option. So php does not have a bug, it simply does not provide a method for using the "-c"
option of iconv, which is unfortunate.
A work-around, as mentioned by another commenter, is to make the system call to the iconv program
with the "-c" option.