php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50746 ICONV broken in CLI
Submitted: 2010-01-14 09:24 UTC Modified: 2010-01-14 12:00 UTC
From: werner at aloah-from-hell dot de Assigned:
Status: Not a bug Package: ICONV related
PHP Version: 5.2.12 OS: Linux X86_64, Kernel 2.6.32.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
46 + 11 = ?
Subscribe to this entry?

 
 [2010-01-14 09:24 UTC] werner at aloah-from-hell dot de
Description:
------------
Hi everybody, 

we've discovered, that the PHP funktion iconv() does not work with the 
PHP-CLI in PHP 5.2.12. PHP is configured with the following Options:

./configure  --enable-magic-quotes --enable-libxml --enable-session --
with-pcre-regex --with-pear --enable-xml --enable-simplexml --enable-
static --enable-safe-mode --enable-sigchild --disable-debug --disable-
rpath --enable-cli --enable-bcmath --enable-exif --enable-gd-native-
ttf --enable-gd-jis-conv --enable-mbstring --enable-mbreg
ex --enable-posix --enable-sockets --with-curl --with-gd=/usr/local --
with-ttf --with-png-dir=/usr --with-jpeg-dir --with-t1lib --with-zlib 
--with-iconv --with-imap=/usr/lib64 --with-imap-ssl --with-mysql --
with-openssl --with-kerberos --with-xpm-dir --with-freetype-dir=/usr -
-with-apxs2=/usr/local/apache2/bin/apxs --disable-cgi --dis
able-ipv6 --disable-pdo --without-sqlite --disable-spl --with-
mcrypt=/usr --enable-soap

ICONV-Support ist active:

server:# php -r 'phpinfo();'|grep -i iconv
...
iconv
iconv support => enabled
iconv implementation => glibc
iconv library version => 2.3.6
iconv.input_encoding => ISO-8859-1 => ISO-8859-1
iconv.internal_encoding => ISO-8859-1 => ISO-8859-1
iconv.output_encoding => ISO-8859-1 => ISO-8859-1

Kind regards,
Werner




Reproduce code:
---------------
<?php
$text = "abcde";
echo iconv('UTF-8', 'ISO-8859-1', $text), PHP_EOL;
?>


Expected result:
----------------
With PHP 5.2.11: 
server:# /usr/local/bin/php /tmp/test.php
abcde
server:# 







Actual result:
--------------
With PHP 5.2.12: 

server:# /usr/local/bin/php /tmp/test.php
server:#

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-14 10:01 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Works fine for me. Enable error reporting and displaying too..or does it actually crash for you..? Try this:

# php -n -d error_reporting=E_ALL -r 'echo iconv("utf-8", "iso-8859-1", "abcde"), PHP_EOL;'

 [2010-01-14 10:13 UTC] werner at aloah-from-hell dot de
Hi, 

thanks for the quick response. I did some more testing ... and it 
seems like the problem is not related to PHP. 

On one machine with PHP 5.2.12 installed:


server1:# php -n -d error_reporting=E_ALL -r 'echo iconv("utf-8", 
"iso-8859-1","abcde"), PHP_EOL;'
abcde
server1:#


server2:# php -n -d error_reporting=E_ALL -r 'echo iconv("utf-8", 
"iso-8859-1","abcde"), PHP_EOL;'
Notice: iconv(): Unknown error (29) in Command line code on line 1
server2:# 


The configure-Options for PHP are the same on both machines. Any 
Ideas? 

regards,
Werner
 [2010-01-14 10:15 UTC] jani@php.net
No idea since I do not know the specs of your servers. :)
Check the diff between their phpinfo() output on iconv section.
 [2010-01-14 10:18 UTC] werner at aloah-from-hell dot de
Hi, 

the hardware-specs are the same - same for the PHP configuration. I'll 
need more testing here ... 

Anyway, thanks again. 

Werner
 [2010-01-14 10:22 UTC] jani@php.net
I'm quite sure they aren't totally identical. Most likely the one where it doesn't work is not installed properly or someone has messed something there. Anyway, since this sure isn't PHP bug -> bogus.
 [2010-01-14 10:27 UTC] werner at aloah-from-hell dot de
Hi, 

unfornately the are the same:

server2:# diff /usr/local/lib/php.ini /home/werner/php.ini
server2:# 

Also the phpinfo-Output for iconv on both systems is identical:

server1:
iconv
iconv support => enabled
iconv implementation => glibc
iconv library version => 2.3.6

Directive => Local Value => Master Value
iconv.input_encoding => ISO-8859-1 => ISO-8859-1
iconv.internal_encoding => ISO-8859-1 => ISO-8859-1
iconv.output_encoding => ISO-8859-1 => ISO-8859-1+


server2:
iconv
iconv support => enabled
iconv implementation => glibc
iconv library version => 2.3.6

Directive => Local Value => Master Value
iconv.input_encoding => ISO-8859-1 => ISO-8859-1
iconv.internal_encoding => ISO-8859-1 => ISO-8859-1
iconv.output_encoding => ISO-8859-1 => ISO-8859-1

Bye,
Werner
 [2010-01-14 10:56 UTC] werner at aloah-from-hell dot de
Hi again, 

I've switched back to PHP 5.2.11 on server2 (on which the iconv-call 
did not work with PHP-CLI 5.2.12) and it's working:

server2:# php -n -d error_reporting=E_ALL -r 'echo iconv("utf-8", 
"iso-8859-1","abcde"), PHP_EOL;'
abcde
server2:#

Compared to PHP-CLI 5.2.12:
server2:# php -n -d error_reporting=E_ALL -r 'echo iconv("utf-8", 
"iso-8859-1","abcde"), PHP_EOL;'
Notice: iconv(): Unknown error (29) in Command line code on line 1
server2:# 

So maybe this could be a PHP issue ? 

Thanks,
Werner








strace php -n -d error_reporting=E_ALL -r 'echo iconv("utf-8", "iso-
8859-1","abcde"), PHP_EOL;'
 [2010-01-14 11:22 UTC] werner at aloah-from-hell dot de
Hi, 

as requested: I've installed the latest Snapshot 
(http://snaps.php.net/php5.2-latest.tar.gz). Same result with this 
version: 

server2:/usr/src/php5.2-201001140930# php -n -d error_reporting=E_ALL -r 
'echo iconv("utf-8", "iso-8859-1","abcde"), PHP_EOL;'
Notice: iconv(): Unknown error (29) in Command line code on line 1
server2:/usr/src/php5.2-20100114093#

Werner
 [2010-01-14 12:00 UTC] werner at aloah-from-hell dot de
Hi, 

I've found a difference in the config.log file. Seems like as in PHP 
5.2.12 (during  configure) this line (which is present in the config.log 
of PHP 5.2.11) is missing:

configure:46684: checking if iconv is glibc's

regards,
Werner
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Oct 28 10:03:33 2021 UTC