diff --git a/CHANGELOG.md b/CHANGELOG.md index b89d227..921b397 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Enh #102: Add `CombinedRegexp` class (@xepozz) +## 2.1.2 July 27, 2023 + +- Bug #105: Fix incorrect split UTF-8 strings in `StringHelper::split()` method (@vjik) + ## 2.1.1 April 28, 2023 - Enh #85: Improve `StringHelper::parsePath()` method annotation (@vjik) diff --git a/src/StringHelper.php b/src/StringHelper.php index 46681ad..6f297ee 100644 --- a/src/StringHelper.php +++ b/src/StringHelper.php @@ -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); } /** diff --git a/tests/StringHelperTest.php b/tests/StringHelperTest.php index a2b15da..4f16c46 100644 --- a/tests/StringHelperTest.php +++ b/tests/StringHelperTest.php @@ -407,6 +407,10 @@ public function dataSplit(): array "\0\nA\nB", ["\0", 'A', 'B'], ], + [ + "технический\nдолг", + ['технический', 'долг'], + ], ]; }