diff --git a/src/ChrisKonnertz/OpenGraph/OpenGraph.php b/src/ChrisKonnertz/OpenGraph/OpenGraph.php index d5462db..d9e6243 100644 --- a/src/ChrisKonnertz/OpenGraph/OpenGraph.php +++ b/src/ChrisKonnertz/OpenGraph/OpenGraph.php @@ -11,7 +11,7 @@ class OpenGraph { /** * The version number */ - const VERSION = '1.0.0'; + const VERSION = '1.0.2'; /** * The name prefix @@ -301,11 +301,11 @@ public function description($description, $maxLength = 250) $description = trim(strip_tags($description)); $description = preg_replace("/\r|\n/", '', $description); - $length = strlen($description); + $length = mb_strlen($description); - $description = substr($description, 0, $maxLength); + $description = mb_substr($description, 0, $maxLength); - if (strlen($description) < $length) { + if (mb_strlen($description) < $length) { $description .= '...'; } diff --git a/tests/OpenGraphTests.php b/tests/OpenGraphTests.php index cb3f867..a7627c6 100644 --- a/tests/OpenGraphTests.php +++ b/tests/OpenGraphTests.php @@ -92,4 +92,18 @@ public function testRenderTags() $hmtl = 'HTML: '.$og; } -} \ No newline at end of file + public function testMbDescription() + { + $og = $this->getDummy(); + + mb_internal_encoding('UTF-8'); + + $char = '☺'; // Unicode char U+263A (white smiley) + + $og->description($char, 1); + $tag = $og->lastTag('description'); + + $this->assertEquals($tag->value, $char); + } + +}