1--TEST-- 2preg_replace() and invalid UTF8 offset 3--SKIPIF-- 4<?php 5if (@preg_match('/./u', '') === false) { 6 die('skip no utf8 support in PCRE library'); 7} 8?> 9--FILE-- 10<?php 11 12$string = "\xc3\xa9 uma string utf8 bem formada"; 13 14var_dump(preg_match('~.*~u', $string, $m, 0, 1)); 15var_dump($m); 16var_dump(preg_last_error() == PREG_BAD_UTF8_OFFSET_ERROR); 17 18var_dump(preg_match('~.*~u', $string, $m, 0, 2)); 19var_dump($m); 20var_dump(preg_last_error() == PREG_NO_ERROR); 21 22echo "Done\n"; 23?> 24--EXPECT-- 25bool(false) 26array(0) { 27} 28bool(true) 29int(1) 30array(1) { 31 [0]=> 32 string(28) " uma string utf8 bem formada" 33} 34bool(true) 35Done 36