php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43815 iconv() throws no error on invalid multibyte input
Submitted: 2008-01-11 10:03 UTC Modified: 2008-01-11 16:26 UTC
From: php at benjaminschulz dot com Assigned:
Status: Not a bug Package: ICONV related
PHP Version: 5.3CVS-2008-01-11 (CVS) OS: Mac OS X 10.5.1
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at benjaminschulz dot com
New email:
PHP Version: OS:

 

 [2008-01-11 10:03 UTC] php at benjaminschulz dot com
Description:
------------
iconv() on OSX throws no error if the input string is not valid on 
multibyte encodings

Reproduce code:
---------------
<?php
function dump($str) {
        printf('"%s" %d bytes, hex:',
                $str,
                strlen($str)
        );
        for($i = 0; $i < strlen($str); $i++) {
                printf(' %02X', ord($str{$i}));
        }

        echo PHP_EOL;
}

// some german umlauts in iso
$str = "f\xf6\xd6\xdf";
error_reporting(E_ALL | E_STRICT);

dump($str);
foreach(array("UTF-16", "UCS-2") AS $enc) {
        echo PHP_EOL, "$enc:", PHP_EOL;
        dump(iconv($enc, $enc, $str));
}



Expected result:
----------------
output of the code on linux:
"f&#65533;&#65533;&#65533;" 4 bytes, hex: 66 F6 D6 DF

UTF-16:

Notice: iconv(): Detected an incomplete multibyte character in input 
string in ... on line 21
"&#65533;&#65533;f&#65533;" 4 bytes, hex: FF FE 66 F6

UCS-2:

Notice: iconv(): Detected an illegal character in input string in ... 
on 
line 21
"f&#65533;" 2 bytes, hex: 66 F6





Actual result:
--------------
the same on osx:
"f&#65533;&#65533;&#65533;" 4 bytes, hex: 66 F6 D6 DF

UTF-16:
"&#65533;&#65533;f&#65533;&#65533;&#65533;" 6 bytes, hex: FE FF 66 F6 D6 
DF

UCS-2:
"f&#65533;&#65533;&#65533;" 4 bytes, hex: 66 F6 D6 DF





Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-11 16:26 UTC] php at benjaminschulz dot com
This seems to be related to the underlying iconv implementation 
(libiconv vs. glibc).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC