|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2010-06-30 15:27 UTC] raphgivernaud at yahoo dot fr
 Description:
------------
When the function fails because of illegal characters, the function never returns false
Test script:
---------------
<?php
    $str = "PATHOLOGIES MÉDICO-CHIRUR. ADUL. PL";
    $str_iconv = iconv('CP850', 'ISO-8859-1', $str );
    var_dump($str_iconv);
?>
Expected result:
----------------
bool(false)
Actual result:
--------------
string(13) "PATHOLOGIES M"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 19:00:02 2025 UTC | 
I don't think this bug was fixed correctly. In particular, iconv doesn't handle '//IGNORE' correctly now. ezyang@javelin:~$ cat test.php <?php var_dump(iconv("UTF-8", "ISO-8859-1//IGNORE", "\xE4\xB8\xAD")); ezyang@javelin:~$ php --version PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011 18:37:10) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans ezyang@javelin:~$ php test.php PHP Notice: iconv(): Detected an illegal character in input string in /home/ezyang/test.php on line 1 PHP Stack trace: PHP 1. {main}() /home/ezyang/test.php:0 PHP 2. iconv() /home/ezyang/test.php:1 string(0) "" ezyang@javelin:~$ phpv 5.4.0RC3 --version PHP 5.4.0RC3 (cli) (built: Dec 16 2011 15:14:12) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2011 Zend Technologies ezyang@javelin:~$ phpv 5.4.0RC3 test.php bool(false)