php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47507 PHP Notice: iconv(): Wrong charset
Submitted: 2009-02-26 07:12 UTC Modified: 2009-05-11 09:57 UTC
From: aboh24 at gmx dot de Assigned:
Status: Not a bug Package: ICONV related
PHP Version: 5.2.9 OS: Solaris 10 / 64-bit
Private report: No CVE-ID: None
 [2009-02-26 07:12 UTC] aboh24 at gmx dot de
Description:
------------
The iconv-function is not working correct on my Solaris 10 / 64-bit.
libiconv and php-5-2-8 (and others) were compiled with CFLAGS=-m64 and CXXFLAGS=-m64 to enable 64-bit binaries.


./configure     --prefix=$PX  \
                --with-config-file-path=$PX/etc \
                --with-apxs2=$PX/apache2/bin/apxs \
                --with-iconv-dir=$PX \
                --with-libxml-dir=$PX \
                --with-zlib=$PX \
                --with-zlib-dir=$PX \
                --enable-mbstring \
                --without-pear

php.ini changes:
extension=bitset.so




Reproduce code:
---------------
#!/home/si/suchopac/rt/bin/php -q
<?php
print_r ( iconv_get_encoding());
print_r(get_loaded_extensions ());
print_r(get_defined_constants(true));

printf(" %s \n",ICONV_IMPL);
printf(" %s \n",ICONV_VERSION);

echo iconv('UTF-8', 'ASCII//TRANSLIT', "test");
echo iconv('ASCII', 'UTF-8//TRANSLIT', "test");

echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT', "test");
echo iconv('ISO-8859-1', 'UTF-8//TRANSLIT', "test");

echo iconv('UTF-8', 'ISO-8859-1', "test"); // WORKING !
echo iconv('ISO-8859-1', 'UTF-8', "test"); // WORKING !


?>


Expected result:
----------------
A verison implementaion and version number and six times "test" 

Actual result:
--------------
Only get 2 "test" string and 4 "tests" fails. 


Array
(
    [input_encoding] => ISO-8859-1
    [output_encoding] => ISO-8859-1
    [internal_encoding] => ISO-8859-1
)
Array
(
    [0] => xmlwriter
    ...
    [16] => mbstring
    [17] => json

    [18] => iconv

    [19] => hash
    [20] => filter
    [21] => date
    [22] => ctype
    [23] => zlib
    [24] => bitset
)
Array
(
...    
        [iconv] => Array
        (
            [ICONV_IMPL] => unknown
            [ICONV_VERSION] => unknown
            [ICONV_MIME_DECODE_STRICT] => 1
            [ICONV_MIME_DECODE_CONTINUE_ON_ERROR] => 2
        )
...
)

 unknown 
 unknown 
PHP Notice:  iconv(): Wrong charset, conversion from `UTF-8' to `ASCII//TRANSLIT' is not allowed in /test.php on line 10
PHP Notice:  iconv(): Wrong charset, conversion from `ASCII' to `UTF-8//TRANSLIT' is not allowed in /test.php on line 11
PHP Notice:  iconv(): Wrong charset, conversion from `UTF-8' to `ISO-8859-1//TRANSLIT' is not allowed in /test.php on line 13
PHP Notice:  iconv(): Wrong charset, conversion from `ISO-8859-1' to `UTF-8//TRANSLIT' is not allowed in /test.php on line 14
testtest

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-26 07:52 UTC] aboh24 at gmx dot de
I rebuilt the codes with -m32 (this is default and means 32-bit binaries) and it is the same problem.
 [2009-02-26 08:59 UTC] aboh24 at gmx dot de
truss ./test.php
...
access("/usr/lib/iconv/geniconvtbl/binarytables/UTF-8%8859-1.bt", R_OK) Err#2 ENOENT
access("/usr/lib/iconv/UTF-8%8859-1.so", R_OK)  = 0
stat("/usr/lib/iconv/UTF-8%8859-1.so", 0xFFBFE8A0) = 0
resolvepath("/usr/lib/iconv/UTF-8%8859-1.so", "/usr/lib/iconv/UTF-8%8859-1.so", 1023) = 30
open("/usr/lib/iconv/UTF-8%8859-1.so", O_RDONLY) = 4
...


Althoug the php was build with a local libiconv and explicit setting of the prefix-path and LD_LIBRARY_PATH and --with-iconv-dir, etc. the system want to load the iconv from  /usr/lib/iconv which do not exists... :-(
 [2009-02-26 10:29 UTC] aboh24 at gmx dot de
This could maybe useful:

user# /usr/lib/iconv/UTF-8%ISO8859-1*
/usr/lib/iconv/UTF-8%ISO8859-11.so


it is mentioned in the truss output of the test php program:

access("/usr/lib/iconv/geniconvtbl/binarytables/UTF-8%ISO-8859-1//TRANSLIT.bt", R_OK) Err#2 ENOENT
access("/usr/lib/iconv/UTF-8%ISO-8859-1//TRANSLIT.so", R_OK) Err#2 ENOENT
open("/usr/lib/iconv/alias", O_RDONLY)          = 3
fstat64(3, 0xFFBFEE60)                          = 0
mmap(0x00000000, 6311, PROT_READ, MAP_SHARED, 3, 0) = 0xFF3A0000
close(3)                                        = 0
munmap(0xFF3A0000, 6311)                        = 0
access("/usr/lib/iconv/geniconvtbl/binarytables/UTF-8%ISO-8859-1//TRANSLIT.bt", R_OK) Err#2 ENOENT
access("/usr/lib/iconv/UTF-8%ISO-8859-1//TRANSLIT.so", R_OK) Err#2 ENOENT
PHP Notice:  iconv(): Wrong charset, conversion from `UTF-8' to `ISO-8859-1//TRANSLIT' is not allowed in /test.php on line 13write(2, " P H P   N o t i c e :  ".., 151)      = 151

write(2, "\n", 1)
 [2009-05-06 20:46 UTC] jani@php.net
I missed this earlier, you're using wrong configure options.
Just change the --with-iconv-dir=$PX to --with-iconv=$PX and try again. 
Note: Do this with clean build dir.

Also, do not paste more test result outputs here, they're no value for 
us. Just telling which tests fail is more useful. 

 [2009-05-07 06:56 UTC] aboh24 at gmx dot de
Sure that I need to use --with-iconv-dir=$PX instead  --with-iconv=$PX? Sorry if I ask because the help message of the configure file display vice versa.


src/php5.2-200904280430 $ ./configure --help | grep iconv
  --without-iconv[=DIR]   Exclude iconv support
  --with-iconv-dir=DIR      XMLRPC-EPI: iconv dir for XMLRPC-EPI

However I will test your suggestion soon.

---

Is there any more infoamtion I can provide to support you? 


---

BTW: What does reason: ICONV_IMPL != "libiconv" mean.
 [2009-05-07 16:08 UTC] jani@php.net
You should actually read the help not grep for iconv in it and you'd 
know what the difference is. Now, did you try it or not?
 [2009-05-11 06:57 UTC] aboh24 at gmx dot de
Changing --with-iconv-dir=$PX  to --with-iconv=$PX fixes the problem. Case can be closed. Thank your very much for your help. Greetings Andreas
 [2009-05-11 09:57 UTC] jani@php.net
As it was basically just user error -> bogus.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 28 16:03:37 2021 UTC