iconv() in PHP returns 'Unknown error 0'

Toomas Aas toomas.aas at raad.tartu.ee
Wed Sep 7 02:23:04 PDT 2005


Hello!

I am managing a FreeBSD 4.11 server which is currently running PHP 
4.3.11.  The server was originally installed in 2003 with an older 
version of PHP and libiconv 1.8. All software has been installed from 
FreeBSD ports. Over the time PHP has been upgraded several times, but 
libiconv has remained untouched:

mail# pkg_info | grep iconv
libiconv-1.8_2      A character set conversion library
php4-iconv-4.3.11   The iconv shared extension for php

There was a time when PHP's iconv() function definitely worked on this 
server, but now it seems to have a problem. I copied and pasted this 
simple test script from www.php.net:

-----------------------------------------------------
<?php
echo iconv("ISO-8859-1", "UTF-8", "This is a test.");
?>
-----------------------------------------------------

When I load this script via the browser, PHP outputs nothing. I have 
error logging set to file only, and in the log file there is this error:

[07-Sep-2005 12:10:07] PHP Notice:  iconv(): Unknown error (0) in 
/storage/www/iconvtest.php on line 2

This is the only error I see in PHP's error log or any other logfile 
with similar timestamp.

The iconv extension is loaded and can be seen in output of phpinfo().

I read that sometimes on FreeBSD you need to use libiconv() instead of 
iconv(), but this is not the case here - when I replace iconv() with 
libiconv() I get "PHP Fatal error:  Call to undefined function: 
libiconv()".

I can successfully run iconv from command line:
$ echo This is a test. > iconvtest
$ iconv -f "ISO-8859-1" -t "UTF-8" iconvtest
This is a test.

Is it possible that my problem is caused by anything *else* than iconv 
library being out of date compared to PHP's iconv extension? If I need 
to update libiconv, I also need to update lot of things that depend on 
it, and this takes some time. If there is some quicker way to get PHP's 
iconv extension functional, I'd prefer to use that for now.

-- 
Toomas Aas --------------------------------------------------------
|arvutivõrgu peaspetsialist | head specialist on computer networks|
|Tartu Linnakantselei       | Tartu City Office                   |
----------------------------------------------------- +372 736 1274




More information about the freebsd-questions mailing list