From 153c3b3e5dded58a1eb749c80049f44ce086399e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 19 Aug 2013 08:52:20 +0000 Subject: [PATCH] fix Shim\Mbstring Thanks to https://github.com/julp/php-utf8/issues/1#issuecomment-22812118 --- class/Patchwork/PHP/Shim/Mbstring.php | 2 +- tests/Patchwork/Tests/PHP/Shim/MbstringTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/class/Patchwork/PHP/Shim/Mbstring.php b/class/Patchwork/PHP/Shim/Mbstring.php index cac1052..709ea00 100644 --- a/class/Patchwork/PHP/Shim/Mbstring.php +++ b/class/Patchwork/PHP/Shim/Mbstring.php @@ -163,7 +163,7 @@ static function mb_convert_case($s, $mode, $encoding = INF) } else { - $s = substr_replace($s, $uchr, $i, $ulen); + $s = substr_replace($s, $uchr, $i - $ulen, $ulen); $len += $nlen - $ulen; $i += $nlen - $ulen; } diff --git a/tests/Patchwork/Tests/PHP/Shim/MbstringTest.php b/tests/Patchwork/Tests/PHP/Shim/MbstringTest.php index b00709f..6f9f023 100644 --- a/tests/Patchwork/Tests/PHP/Shim/MbstringTest.php +++ b/tests/Patchwork/Tests/PHP/Shim/MbstringTest.php @@ -50,9 +50,9 @@ function testmb_convert_enconding() */ function testStrCase() { - $this->assertSame( 'déjà σσς', p::mb_strtolower('DÉJÀ Σσς') ); - $this->assertSame( 'DÉJÀ ΣΣΣ', p::mb_strtoupper('Déjà Σσς') ); - $this->assertSame( 'Déjà Σσσ', p::mb_convert_case('DÉJÀ ΣΣΣ', MB_CASE_TITLE) ); + $this->assertSame( 'déjà σσς iiıi', p::mb_strtolower('DÉJÀ Σσς İIıi') ); + $this->assertSame( 'DÉJÀ ΣΣΣ İIII', p::mb_strtoupper('Déjà Σσς İIıi') ); + $this->assertSame( 'Déjà Σσσ Iı Ii', p::mb_convert_case('DÉJÀ ΣΣΣ ıı iI', MB_CASE_TITLE) ); } /**