Skip to content

Commit 7f64374

Browse files
committed
Fix #125 - Make str_split multibyte save
str_split() will split into bytes, rather than characters when dealing with a multi-byte encoded string. Use mb_str_split() to split the string into code points.
1 parent 21e12d1 commit 7f64374

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"require": {
3030
"php": ">=7.3",
3131
"ext-mbstring": "*",
32-
"ext-pcre": "*"
32+
"ext-pcre": "*",
33+
"symfony/polyfill-mbstring": "^1"
3334
},
3435
"require-dev": {
3536
"phpunit/phpunit": "^8 || ^9",

lib/jblond/Diff/SequenceMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function setSequences($version1, $version2): void
136136
public function setSeq1($version1): void
137137
{
138138
if (!is_array($version1)) {
139-
$version1 = str_split($version1);
139+
$version1 = mb_str_split($version1);
140140
}
141141
if ($version1 == $this->old) {
142142
return;
@@ -159,7 +159,7 @@ public function setSeq1($version1): void
159159
public function setSeq2($version2): void
160160
{
161161
if (!is_array($version2)) {
162-
$version2 = str_split($version2);
162+
$version2 = mb_str_split($version2);
163163
}
164164
if ($version2 == $this->new) {
165165
return;

0 commit comments

Comments
 (0)