xref: /php-src/ext/mbstring/tests/bug49354.phpt (revision 3fa836f7)
1--TEST--
2Bug #49354 (mb_strcut() cuts wrong length when offset is in the middle of a multibyte character)
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7$crap = 'AåBäCöDü'; // sequence of 1-byte and 2-byte chars: [41 c3a5 42 c3a4 43 c3b6 44 c3bc]
8var_dump(mb_strcut($crap, 0, 100, 'UTF-8'));
9var_dump(mb_strcut($crap, 1, 100, 'UTF-8')); // skip over A
10var_dump(mb_strcut($crap, 2, 100, 'UTF-8')); // cut in middle of å
11var_dump(mb_strcut($crap, 3, 100, 'UTF-8')); // skip over Aå
12var_dump(mb_strcut($crap, 12, 100, 'UTF-8'));
13var_dump(mb_strcut($crap, 13, 100, 'UTF-8'));
14
15?>
16--EXPECT--
17string(12) "AåBäCöDü"
18string(11) "åBäCöDü"
19string(11) "åBäCöDü"
20string(9) "BäCöDü"
21string(0) ""
22string(0) ""
23