diff --git a/src/Modules/Id3v2.php b/src/Modules/Id3v2.php index 5641439..124c6b4 100644 --- a/src/Modules/Id3v2.php +++ b/src/Modules/Id3v2.php @@ -160,6 +160,7 @@ private function parseItem(&$frames) switch ($encoding) { case self::HAS_BOM: + $value = Bom::removeBom($value); break; case self::UTF_16: $value = "\xFE\xFF" . $value; @@ -167,11 +168,8 @@ private function parseItem(&$frames) case self::UTF_8: break; default: - $value = utf8_encode($value); } - $value = Bom::removeBom($value); - # Strings are unreliably terminated with nulls, so just strip any that are present $value = rtrim($value, "\0"); diff --git a/tests/Modules/Id3v2Test.php b/tests/Modules/Id3v2Test.php index e0be3e2..5979173 100644 --- a/tests/Modules/Id3v2Test.php +++ b/tests/Modules/Id3v2Test.php @@ -70,6 +70,13 @@ public function testUtf16WithBom() $module = $this->getEncoded(); assertSame("To Speak, to Listen", $module->getAlbum()); } + public function testWin1251() + { + $file = new File(__DIR__ . "/../data/cp1251.mp3"); + $module = new Id3v2(); + $module->open($file); + assertSame("Аквариум", iconv("cp1251", "utf-8", $module->getArtist())); + } public function testUtf16WithoutBom() { $module = $this->getEncoded(); diff --git a/tests/data/cp1251.mp3 b/tests/data/cp1251.mp3 new file mode 100644 index 0000000..e2f0d61 Binary files /dev/null and b/tests/data/cp1251.mp3 differ