php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44424 iconv() is not working
Submitted: 2008-03-13 03:06 UTC Modified: 2008-03-17 00:30 UTC
From: yes298 at gmail dot com Assigned:
Status: Not a bug Package: ICONV related
PHP Version: 5.2.5 OS: FreeBSD 7.0(x64)
Private report: No CVE-ID: None
 [2008-03-13 03:06 UTC] yes298 at gmail dot com
Description:
------------
on FreeBSD 6.2(x64) and 7.0(x64), use phpinfo() show that iconv() is enabled, but it can NOT work properly, only big5 or gb2312 convert to utf-8 is ok, but can NOT convert between big5 and gb2312 or gbk.

phpinfo() result as below:

iconv support  enabled  
iconv implementation  libiconv  
iconv library version  1.11  

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 

Using function var_dump(get_extension_funcs("iconv")); to get info as below:

array(11) { [0]=> string(5) "iconv" [1]=> string(16) "ob_iconv_handler" [2]=> string(18) "iconv_get_encoding" [3]=> string(18) "iconv_set_encoding" [4]=> string(12) "iconv_strlen" [5]=> string(12) "iconv_substr" [6]=> string(12) "iconv_strpos" [7]=> string(13) "iconv_strrpos" [8]=> string(17) "iconv_mime_encode" [9]=> string(17) "iconv_mime_decode" [10]=> string(25) "iconv_mime_decode_headers" } 

Reproduce code:
---------------
$a = "???w?f?~"; 
$b = iconv('big5','gb2312',$a); 
$c = iconv('big5','gbk',$a); 

echo 'TC: ' . $a .'<br>'; 
echo 'SC: ' . $b .'<br>';
echo 'gbk: ' . $c .'<br>';


Expected result:
----------------
???w?f?~
????˵??
????˵??


Actual result:
--------------
???w?f?~
??
??

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-13 11:53 UTC] jani@php.net
Does the same work using the command line iconv utility?
 [2008-03-14 00:25 UTC] yes298 at gmail dot com
Yes, even using freeBSD command iconv is also fail to convert between
big5 and gb2312

Is it the problem of FreeBSD command libconv?

I would like to know whether PHP iconv() funciton will directly 
call system libconv() to do convertion?
 [2008-03-17 00:30 UTC] jani@php.net
Yes, PHP's iconv() is basically just a wrapper for the libiconv() function. And as the thing doesn't work with the iconv utility itself, it can't really be PHP bug. I suggest you report this to the iconv developers instead.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 06:03:37 2021 UTC