aramds / php-reader

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

Default encoding not used for added text frames #72

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi Sven,

Thanks for the library!

<code>
    $id3 = new Zend_Media_Id3v2(array("version" => 3.0, "encoding" => Zend_Media_Id3_Encoding::ISO88591, "compat" => true));

    $tcon = new Zend_Media_Id3_Frame_Tcon();
    $tcon->setText('Bible Teaching');
    $id3->addFrame($tcon);

    $id3->write($talkFilePath);
</code>

When creating a new text frame with no options (for e.g. see #1), the text 
encoding defaults to UTF-8 in the constructor (see #2). Later when the frame is 
added to the ID3v2 tag, the frame options are set including the default 
encoding (see #3). However, the encoding variable in the text frame is never 
updated. This causes problems because the UTF-8 encoding is not supported by 
version ID3v2.3.

I now know I could explicitly specify the encoding option each time I create a 
new text frame (for e.g. see #4) but that can be quite tedious when adding lots 
of text frames.

I've attached a patch which modifies TextFrame.php to delay the setting of the 
default encoding until after addFrame() sets the encoding option.

1) new Zend_Media_Id3_Frame_Tcon();
2) $this->setEncoding($this->getOption('encoding', 
Zend_Media_Id3_Encoding::UTF8)); on line 68 in TextFrame.php
3) $frame->setOptions($this->getOptions()); on line 364 in Id3v2.php
4) $opts = array("encoding" => Zend_Media_Id3_Encoding::ISO88591); new 
Zend_Media_Id3_Frame_Tcon(null, $opts);

Original issue reported on code.google.com by ja...@digitaledgeit.com.au on 14 Oct 2012 at 10:02

Attachments: