xref: /php-src/ext/mbstring/tests/bug49536.phpt (revision 0e7160b8)
1--TEST--
2Bug #49536 (mb_detect_encoding() returns incorrect results when strict_mode is turned on)
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7// non-strict mode
8var_dump(mb_detect_encoding("A\x81", "SJIS", false));
9// strict mode
10var_dump(mb_detect_encoding("A\x81", "SJIS", true));
11// non-strict mode
12var_dump(mb_detect_encoding("\xc0\x00", "UTF-8", false));
13// strict mode
14var_dump(mb_detect_encoding("\xc0\x00", "UTF-8", true));
15
16// Strict mode with multiple candidate encodings
17// This input string is invalid in ALL the candidate encodings:
18echo "== INVALID STRING - UTF-8 and SJIS ==\n";
19var_dump(mb_detect_encoding("\xFF\xFF", ['SJIS', 'UTF-8'], true));
20?>
21--EXPECT--
22string(4) "SJIS"
23bool(false)
24string(5) "UTF-8"
25bool(false)
26== INVALID STRING - UTF-8 and SJIS ==
27bool(false)
28