xref: /PHP-7.1/ext/pcre/tests/bug27103.phpt (revision 113213f0)
1--TEST--
2Bug #27103 (preg_split('//u') incorrectly splits UTF-8 strings into octets)
3--SKIPIF--
4<?php
5if (@preg_match('/./u', '') === false) {
6	die('skip no utf8 support in PCRE library');
7}
8?>
9--FILE--
10<?php
11function iter($ar)
12{
13	foreach ($ar as $c) {
14		echo htmlentities($c, 0, "UTF-8"), ": ", strlen($c), "\n";
15	}
16}
17$teststr = "\xe2\x82\xac hi there";
18iter(preg_split('//u', $teststr, -1, PREG_SPLIT_NO_EMPTY));
19preg_match_all('/./u', $teststr, $matches);
20iter($matches[0]);
21?>
22--EXPECT--
23&euro;: 3
24 : 1
25h: 1
26i: 1
27 : 1
28t: 1
29h: 1
30e: 1
31r: 1
32e: 1
33&euro;: 3
34 : 1
35h: 1
36i: 1
37 : 1
38t: 1
39h: 1
40e: 1
41r: 1
42e: 1
43