1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-09-01 09:03:03 +02:00

Fix for collapseWhitespace() not being able to handle multibyte space characters

This commit is contained in:
Daniel St. Jules
2013-08-06 22:39:47 -04:00
parent 7a64dad935
commit f1abc38c17
6 changed files with 25 additions and 16 deletions

View File

@@ -97,7 +97,7 @@ of the former is the following:
```php
use Stringy\Stringy as S;
echo S::create("Fòô Bàř", 'UTF-8')->collapseWhitespace()->swapCase(); // 'fÒÔ bÀŘ'
echo S::create('Fòô Bàř', 'UTF-8')->collapseWhitespace()->swapCase(); // 'fÒÔ bÀŘ'
```
`Stringy\Stringy` contains a __toString() method, which returns the current
@@ -108,8 +108,8 @@ Using the static wrapper, an alternative is the following:
```php
use Stringy\StaticStringy as S;
$string = S::collapseWhitespace("Fòô Bàř", 'UTF-8');
echo S::swapCase($string, 'UTF-8'); // 'fÒÔ bÀŘ''
$string = S::collapseWhitespace('Fòô Bàř', 'UTF-8');
echo S::swapCase($string, 'UTF-8'); // 'fÒÔ bÀŘ'
```
## Methods
@@ -151,10 +151,11 @@ S::camelize('Camel-Case'); // 'camelCase'
$stringy->collapseWhitespace()
S::collapseWhitespace(string $str)
S::collapseWhitespace(string $str [, string $encoding ])
Trims the string and replaces consecutive whitespace characters with a
single space. This includes tabs and newline characters.
single space. This includes tabs and newline characters, as well as
multibyte whitespace such as the thin space and ideographic space.
```php
S::create(' Ο συγγραφέας ')->collapseWhitespace();