kirankoyande / php-reader

Automatically exported from code.google.com/p/php-reader
0 stars 0 forks source link

Read TRCK frame in UTF-16 #45

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am not sure if this conforms to id3 standards,
but I do encounter mp3 file's trck frame that is encoded in UTF-16.

However I can see that in the Trck.php encoding is ignored presuming this frame 
is always in iso-8859-1.

Original issue reported on code.google.com by line...@gmail.com on 27 Sep 2010 at 3:47

GoogleCodeExporter commented 9 years ago
If there's BOM in the beginning of Trck frame, it won't be interpreted properly.

Original comment by line...@gmail.com on 27 Sep 2010 at 3:54

GoogleCodeExporter commented 9 years ago
TRCK is a text frame containing numberic strings. Using UTF-16 in numeric value 
does not conform to the standard: _"All numeric strings and URLs are always 
encoded as ISO-8859-1"_. Hence, TRCK consideres data in ISO-8859-1 encoding and 
doesn't even check the encoding set in the frame. However, it would be pretty 
simple thing to do to add a check for the encoding and convert the string 
accordingly. There are a lot of other frames that does it already. I don't have 
the time to do it just now but should you not want to do the change yourself 
and provide here as a patch, I can have a look at it later. 

Original comment by svollbehr on 27 Sep 2010 at 6:18

GoogleCodeExporter commented 9 years ago
I decided not to implement non-standard support for UTF-16 encoded numbers for 
this field. However, please have a look at how the TXXX class converts the 
values into different encoding. One can easily patch the TRCK class to do the 
same.

Original comment by svollbehr on 28 Dec 2010 at 10:41

GoogleCodeExporter commented 9 years ago
Is there something bad in replacing

$this->_reader->skip(1);
$this->setText($this->_reader->readString8($this->_reader->getSize()));

with

$encoding = $this->_reader->readUInt8();
$this->setText(
    $this->_convertString(
        array($this->_reader->read($this->_reader->getSize())),
        $encoding
    )
);

? I've tested it on file with trck containing BOM 0xFFFE (UTF-16LE) and 
ISO-8859-1 encoded values, both types worked.

Original comment by mfthe...@gmail.com on 10 Mar 2012 at 11:40