From 7b88b4f3da0864ba1f4931d9f92ef85825ee4406 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 7 Jan 2015 01:12:05 +0100 Subject: [PATCH] Support for various Unicode spaces in toAscii() * no-break space (U+00A0) * thin space (U+2009) * narrow no-break space (U+202F) * ideographic space (U+3000) --- src/Stringy.php | 4 +++- tests/CommonTest.php | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Stringy.php b/src/Stringy.php index a8bb803..fae95d1 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -508,7 +508,9 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess 'TS' => array('Ц'), 'YA' => array('Я'), 'YU' => array('Ю'), - 'ZH' => array('Ж') + 'ZH' => array('Ж'), + ' ' => array("\xC2\xA0", "\xE2\x80\x89", "\xE2\x80\xAF", + "\xE3\x80\x80"), ); foreach ($charsArray as $key => $value) { diff --git a/tests/CommonTest.php b/tests/CommonTest.php index 4852ae1..0f5ca0b 100644 --- a/tests/CommonTest.php +++ b/tests/CommonTest.php @@ -189,7 +189,10 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase array('perevirka', 'перевірка'), array('lysaya gora', 'лысая гора'), array('shchuka', 'щука'), - array('', '漢字') + array('', '漢字'), + array(' ', ' '), // no-break space + array(' 1 2 3 ', '  1  2  3  '), // ideographic spaces + array(' ', '   '), // thin space and space ); }