ID: 43815
User updated by: php at benjaminschulz dot com
Reported By: php at benjaminschulz dot com
-Status: Open
+Status: Bogus
Bug Type: ICONV related
Operating System: Mac OS X 10.5.1
PHP Version: 5.3CVS-2008-01-11 (CVS)
New Comment:
This seems to be related to the underlying iconv implementation
(libiconv vs. glibc).
Previous Comments:
------------------------------------------------------------------------
[2008-01-11 10:03:55] 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���" 4 bytes, hex: 66 F6 D6 DF
UTF-16:
Notice: iconv(): Detected an incomplete multibyte character in input
string in ... on line 21
"��f�" 4 bytes, hex: FF FE 66 F6
UCS-2:
Notice: iconv(): Detected an illegal character in input string in ...
on
line 21
"f�" 2 bytes, hex: 66 F6
Actual result:
--------------
the same on osx:
"f���" 4 bytes, hex: 66 F6 D6 DF
UTF-16:
"��f���" 6 bytes, hex: FE FF 66 F6
D6
DF
UCS-2:
"f���" 4 bytes, hex: 66 F6 D6 DF
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43815&edit=1