Skip to content

Commit

Permalink
Fix incorrect split UTF-8 strings (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Jul 27, 2023
1 parent 2d206ff commit 0953616
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,7 @@

## 2.1.2 under development

- no changes in this release.
- Bug #105: Fix incorrect split UTF-8 strings in `StringHelper::split()` method (@vjik)

## 2.1.1 April 28, 2023

Expand Down
2 changes: 1 addition & 1 deletion src/StringHelper.php
Expand Up @@ -496,7 +496,7 @@ public static function base64UrlDecode(string $input): string
public static function split(string $string, string $separator = '\R'): array
{
$string = preg_replace('(^\s*|\s*$)', '', $string);
return preg_split('~\s*' . $separator . '\s*~', $string, -1, PREG_SPLIT_NO_EMPTY);
return preg_split('~\s*' . $separator . '\s*~u', $string, -1, PREG_SPLIT_NO_EMPTY);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/StringHelperTest.php
Expand Up @@ -407,6 +407,10 @@ public function dataSplit(): array
"\0\nA\nB",
["\0", 'A', 'B'],
],
[
"технический\nдолг",
['технический', 'долг'],
],
];
}

Expand Down

0 comments on commit 0953616

Please sign in to comment.