mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Copy UTF-8 flag for str_repeat
This commit is contained in:
parent
99b86141ae
commit
c2d4bafc4f
2 changed files with 12 additions and 0 deletions
|
@ -5059,6 +5059,7 @@ PHP_FUNCTION(str_repeat)
|
|||
/* Initialize the result string */
|
||||
result = zend_string_safe_alloc(ZSTR_LEN(input_str), mult, 0, 0);
|
||||
result_len = ZSTR_LEN(input_str) * mult;
|
||||
ZSTR_COPY_CONCAT_PROPERTIES(result, input_str);
|
||||
|
||||
/* Heavy optimization for situations where input string is 1 byte long */
|
||||
if (ZSTR_LEN(input_str) == 1) {
|
||||
|
|
|
@ -107,6 +107,14 @@ $s = $o . $o;
|
|||
var_dump($s);
|
||||
var_dump(zend_test_is_string_marked_as_valid_utf8($s));
|
||||
|
||||
echo "str_repeat:\n";
|
||||
$string = "a";
|
||||
$string_concat = str_repeat($string, 100);
|
||||
var_dump(zend_test_is_string_marked_as_valid_utf8($string_concat));
|
||||
$string = "\xff";
|
||||
$string_concat = str_repeat($string, 100);
|
||||
var_dump(zend_test_is_string_marked_as_valid_utf8($string_concat));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Empty strings:
|
||||
|
@ -148,3 +156,6 @@ bool(true)
|
|||
Concatenation of objects:
|
||||
string(2) "zz"
|
||||
bool(true)
|
||||
str_repeat:
|
||||
bool(true)
|
||||
bool(false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue