Bug #63450 [Com]: iconv returns false when illegal character encountered

From: Date: Wed, 23 Oct 2013 16:18:49 +0000
Subject: Bug #63450 [Com]: iconv returns false when illegal character encountered
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182410@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63450&edit=1 ID: 63450 Comment by: daniel at kukiela dot pl Reported by: trollofdarkness at gmail dot com Summary: iconv returns false when illegal character encountered Status: Re-Opened 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. Will this bug be resolved? I use PHP on Debian and i cannot upgrade Debian to version 7.x and PHP to 5.5.x (via dotdeb.org) because of this problem. Functions, which uses glibc (like iconv or htmlspecialchars) returns empty string. How to test iconv: function testIconv1(){ set_error_handler('doNothing'); $r = iconv('utf-8', 'ascii//IGNORE', "\xCE\xB1" . str_repeat('a', 9000)); restore_error_handler(); if ($r === false) { $code = "UNUSABLE"; } elseif (($c = strlen($r)) < 9000) { $code = "TRUNCATES"; } elseif ($c > 9000) { $code = "BUGGY"; } else { $code = "OK"; } return $code; } function doNothing(){} echo testIconv1(); how to test htmlspecialchars: var_dump(htmlspecialchars('żółw')); //returns an empty string I can't upgrade serwer software because of this more than 1 year old bug. Please, do something with that (i would like to use PHP 5.3 instead of PHP 5.3). Regards, Daniel Previous Comments: ------------------------------------------------------------------------ [2013-03-07 20:00:31] ezyang@php.net This is a dupe of https://bugs.php.net/bug.php?id=48147 (not that I don't think it should be fixed!) Here is the glibc bug: http://sourceware.org/bugzilla/show_bug.cgi?id=13541 ------------------------------------------------------------------------ [2012-11-08 02:24:27] aharvey@php.net Reopening per above. Anyone more familiar with iconv and the build system want to opine? ------------------------------------------------------------------------ [2012-11-07 21:58:24] trollofdarkness at gmail dot com Hi, So, I had a look at it and this is not a libiconv related bug. It is a glibc related bug (so, iconv, but the glibc implementation) as I was not using the GNU libiconv implementation but the glibc one. Actually, I had the 2.7 version of glibc. I tested on another machine - a Ubuntu 12.04 LTS server - where the glibc version was 2.14 and, indeed, the bug was not present. So it is in recent versions of glibc. To correct the problem on Debian, you can recompile PHP to use the libiconv implementation instead of the glibc one. But it is NOT quite easy because PHP looks for glic implementation BEFORE libiconv and select it if present... even with every --with-iconv=something parameter you can use when running ./configure. I used the solution presented there : <http://stackoverflow.com/questions/4743080/how-can-i-force-php-to-use-the- libiconv-version-of-iconv-instead-of-the-centos-i/4851065#4851065> and as one of the comments states, I had to change global configure file and not (only) the one of ext/iconv. (note that, first, you have to actually download libiconv and compile it... but that's just wget && ./configure && make && make install). I now have the libiconv implementation in use and it's working perfectly. I storngly think PHP should change the behaviour of the configure file, we should not have to edit it to use the libiconv implementation, we should just be able to use the right configure parameter! ------------------------------------------------------------------------ [2012-11-06 22:19:13] trollofdarkness at gmail dot com 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. ------------------------------------------------------------------------ [2012-11-06 21:54:00] rasmus@php.net 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 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=63450 -- Edit this bug report at https://bugs.php.net/bug.php?id=63450&edit=1

« previous php.bugs (#182410) next »