From:             php at benjaminschulz dot com
Operating system: Mac OS X 10.5.1
PHP version:      5.3CVS-2008-01-11 (CVS)
PHP Bug Type:     ICONV related
Bug description:  iconv() throws no error on invalid multibyte input

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





-- 
Edit bug report at http://bugs.php.net/?id=43815&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43815&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43815&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43815&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43815&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43815&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43815&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43815&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43815&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43815&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43815&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43815&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43815&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43815&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43815&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43815&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43815&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43815&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43815&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43815&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43815&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43815&r=mysqlcfg

Reply via email to