From f41f276bdd7ed1ff56e004e50ca6a15e5ca5687f Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 9 Oct 2022 12:30:20 +0545 Subject: [PATCH] Remove utf8_encode --- lib/Parser/MimeDir.php | 4 +--- tests/VObject/StringUtilTest.php | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Parser/MimeDir.php b/lib/Parser/MimeDir.php index b90cd1a4..10bf4aaf 100644 --- a/lib/Parser/MimeDir.php +++ b/lib/Parser/MimeDir.php @@ -478,10 +478,8 @@ protected function readProperty(string $line) switch (strtolower($charset)) { case 'utf-8': break; - case 'iso-8859-1': - $property['value'] = utf8_encode($property['value']); - break; case 'windows-1252': + case 'iso-8859-1': $property['value'] = mb_convert_encoding($property['value'], 'UTF-8', $charset); break; default: diff --git a/tests/VObject/StringUtilTest.php b/tests/VObject/StringUtilTest.php index 8c1460ee..4dd8bab7 100644 --- a/tests/VObject/StringUtilTest.php +++ b/tests/VObject/StringUtilTest.php @@ -29,9 +29,10 @@ public function testUTF8ControlChar(): void public function testConvertToUTF8nonUTF8(): void { + // 0xBF is an ASCII upside-down question mark $string = StringUtil::convertToUTF8(chr(0xBF)); - $this->assertEquals(utf8_encode(chr(0xBF)), $string); + $this->assertEquals(mb_convert_encoding(chr(0xBF), 'UTF-8', 'ISO-8859-1'), $string); } public function testConvertToUTF8IsUTF8(): void