Edit report at https://bugs.php.net/bug.php?id=63450&edit=1
ID: 63450
Comment by: trollofdarkness at gmail dot com
Reported by: trollofdarkness at gmail dot com
Summary: iconv returns false when illegal character
encountered
Status: Not a bug
Type: Bug
Package: ICONV related
Operating System: Debian 5 Lenny
PHP Version: 5.4.8
Block user comment: N
Private report: N
New Comment:
Hi Rasmus,
Thanks for your help!
I will have a look at that on the spot and will post an update to say if it
works
to downgrade the libiconv.
Previous Comments:
------------------------------------------------------------------------
[2012-11-06 21:54:00] [email protected]
This is not a PHP issue. This is a change in recent versions of libiconv. If
you
link PHP against an older version of libiconv it will work again or you can use
mbstring_convert_encoding(). And we have a new uconverter extension feature
coming that will do a better job than either of these. See
https://wiki.php.net/rfc/uconverter
------------------------------------------------------------------------
[2012-11-06 21:45:33] trollofdarkness at gmail dot com
Description:
------------
Hi everyone,
I have been, since I think the version 5.3.x is out (and still with 5.4.8),
experiencing issues with iconv.
Especially, when an illegal character is encountered and the //IGNORE flag is
set on the target charset, the function returns FALSE instead of just skipping
this character.
This is problematic because if a single character in a 50 000 chars long string
is "illegal" then the output is nothing, just for one char...
It does not happen with the TRANSLIT flag.
I experienced that with UTF8 (from) and ISO-8859-15 (to) charsets, I did not
test with other ones. Below is an example to reproduce the bug.
Note : I saw there are other bug reports about similar issues, but they're all
saying the string is cut... In my case, it literally returns false. So, might
be
different?
Test script:
---------------
<?php
$str = "
foo
è
foo
";
$result = iconv("UTF-8", "ISO-8859-15"."//IGNORE", $str);
var_dump($result); // false, instead of "foo ... foo"
?>
Expected result:
----------------
foo
foo
Actual result:
--------------
false
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63450&edit=1