Skip to content

Commit 74618ab

Browse files
CrazyMuffindg
authored andcommitted
Strings::trim() trims unicode spaces and ZWSP (#304)
1 parent a9d127d commit 74618ab

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Utils/Strings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Strings
2121
{
2222
use Nette\StaticClass;
2323

24-
public const TrimCharacters = " \t\n\r\0\x0B\u{A0}";
24+
public const TrimCharacters = " \t\n\r\0\x0B\u{A0}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200A}\u{200B}";
2525

2626
/** @deprecated use Strings::TrimCharacters */
2727
public const TRIM_CHARACTERS = self::TrimCharacters;

tests/Utils/Strings.trim().phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Assert::same('x', Strings::trim(" \t\n\r\x00\x0B\u{A0}x"));
1717
Assert::same('a b', Strings::trim(' a b '));
1818
Assert::same(' a b ', Strings::trim(' a b ', ''));
1919
Assert::same('e', Strings::trim("\u{158}e-", "\u{158}-")); // Ře-
20+
Assert::same('foo', Strings::trim("\u{2000}\u{200B}foo"));
2021

2122
Assert::exception(
2223
fn() => Strings::trim("\xC2x\xA0"),

0 commit comments

Comments
 (0)