Closed wizwizcao closed 5 years ago
Thanks for info. Will see it soon.
Hey, i have a small fix for it. I spent a lot of time debugging with that, but at the end it works adding the nul char at the end of the string. I didn't do a pull request because idk if the code will break with another songs, but at least works for me. I have forked your repo:
https://github.com/parzibyte/Mp3Info/blob/master/src/Mp3Info.php
The important code is, in the else
of the function handleTextFrame put this:
$data["information"] .= chr(0);
So the function is like this:
private function handleTextFrame($frameSize, $raw)
{
$data = unpack('C1encoding/A' . ($frameSize - 1) . 'information', $raw);
if ($data['encoding'] == 0x00) # ISO-8859-1
return mb_convert_encoding($data['information'], 'utf-8', 'iso-8859-1');
else{ # utf-16
# Fix the missing last char of the info bug
# Add NUL character at the end of the string.
# Don't ask, just enjoy. Idk why it works, but it works!
$data["information"] .= chr(0);
return mb_convert_encoding($data['information'], 'utf-8', 'utf-16');
}
}
Hope it helps! and thank you for making this library :-)
I think that's good, added in 9d5d136
For example, in tags2, the TPE1 shows "Bruno Mar" which should be assumed "Bruno Mars". This issue seems applies to all the tags2 fields. Guess the root cause is converting the non-ISO-8859-1 data from 'utf-16' to 'utf-8'.