xref: /PHP-8.1/ext/mbstring/tests/bug49528.phpt (revision 39131219)
1--TEST--
2Bug #49528 (UTF-16 strings prefixed by BOM wrongly converted)
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7var_dump(bin2hex(mb_convert_encoding("\xff\xfe\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
8var_dump(bin2hex(mb_convert_encoding("\xfe\xff\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
9var_dump(bin2hex(mb_convert_encoding("\xff\xfe\xff\xfe\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
10var_dump(bin2hex(mb_convert_encoding("\xff\xfe\xfe\xff\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
11var_dump(bin2hex(mb_convert_encoding("\xfe\xff\xff\xfe\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
12var_dump(bin2hex(mb_convert_encoding("\xfe\xff\xfe\xff\x01\x02\x03\x04", "UCS-2BE", "UTF-16")));
13?>
14--EXPECT--
15string(8) "02010403"
16string(8) "01020304"
17string(12) "feff02010403"
18string(12) "fffe02010403"
19string(12) "fffe01020304"
20string(12) "feff01020304"
21