php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75784 The string must be interrupted by a carry, and in fact, it is replaced with cha
Submitted: 2018-01-09 09:08 UTC Modified: 2018-01-09 10:13 UTC
From: vklimin at 510710 dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 7.1.13 OS: Windows 10
Private report: No CVE-ID: None
 [2018-01-09 09:08 UTC] vklimin at 510710 dot com
Description:
------------
An incorrect behavior of the function was detected when working with text in the UTF-8 format. 
Instead of changing characters, characters disappear.
The string must be interrupted by a carry, and in fact, it is replaced with characters from another encoding.

Test script:
---------------
<?php

$a = "Это тестовая строка";

var_dump( preg_replace( '/(те)сто(вая)/u', "\1\n\2", $a ) );
var_dump( preg_replace( '/(те)сто(вая)/u', "\1" . "\n" . "\2", $a ) );
var_dump( preg_replace( '/(те)сто(вая)/u', '\1' . "\n" . '\2', $a ) );
?>

Expected result:
----------------
string(23) "Это те
вая строка"
string(23) "Это те
вая строка"
string(31) "Это те
вая строка"

Actual result:
--------------
string(23) "Это 
 строка"
string(23) "Это 
 строка"
string(31) "Это те
вая строка"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-09 09:12 UTC] vklimin at 510710 dot com
Expected result:
----------------
string(31) "Это те
вая строка"
string(31) "Это те
вая строка"
string(31) "Это те
вая строка"
 [2018-01-09 10:13 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: Regexps related +Package: PCRE related
 [2018-01-09 10:13 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

"\1" == chr(1)
http://php.net/manual/ru/language.types.string.php#language.types.string.syntax.double
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 13:01:30 2024 UTC