|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-11 16:26 UTC] php at benjaminschulz dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 15:00:01 2025 UTC |
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