summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2012-03-28 13:40:12 +0000
committerChristian Schneider2012-03-28 13:40:12 +0000
commita7ac24d9f9698ff0a1d42268d79f74cd21f70eb4 (patch)
tree1ddae8a9e757a25e1033e234a5182245fb865a6e
parent2c7860119626cdf65fa4d7de38b7e0a1fdb816df (diff)
downloaditools-a7ac24d9f9698ff0a1d42268d79f74cd21f70eb4.tar.gz
itools-a7ac24d9f9698ff0a1d42268d79f74cd21f70eb4.tar.bz2
itools-a7ac24d9f9698ff0a1d42268d79f74cd21f70eb4.zip
Fix it::ucwords and added tests for it::ucfirst and it::ucwords
-rw-r--r--it.class2
-rwxr-xr-xtests/it.t4
2 files changed, 5 insertions, 1 deletions
diff --git a/it.class b/it.class
index b4a0d9e..6a796d4 100644
--- a/it.class
+++ b/it.class
@@ -432,7 +432,7 @@ static function ucfirst($string)
*/
static function ucwords($string)
{
- return preg_replace_callback('/\b\w/u', function($m) { return mb_strtoupper($m[1]); }, mb_strtolower($string));
+ return preg_replace_callback('/\b\w/u', function($m) { return mb_strtoupper($m[0]); }, mb_strtolower($string));
}
static function substr_replace($string, $replacement, $start, $length)
diff --git a/tests/it.t b/tests/it.t
index 408d84a..8e4a7e2 100755
--- a/tests/it.t
+++ b/tests/it.t
@@ -347,6 +347,10 @@ is(it::date('datetime', 1000000.543), it::date('datetime', "1000000"), '... larg
is(it::date('time', "10.5"), "10:05", 'interpret string with points with strtotime');
is(it::date('time', "10.05"), "10:05", 'interpret string with points with strtotime');
+# it::uc*
+is(it::ucfirst('foo bär über'), 'Foo bär über');
+is(it::ucwords('foo bär über'), 'Foo Bär Über');
+
# it::substr_replace
is(it::substr_replace('abcdefgh', 'xyz', 2, 4), substr_replace('abcdefgh', 'xyz', 2, 4), 'it::substr_replace the same as substr_replace for ascii');
is(it::substr_replace('✔☯♥', '☃☃', 1, 1), '✔☃☃♥', 'it::substr_replace for utf-8');