How to write multiple values to one ID3v2.4 frame?

Duke Yin yindesu at gmail.com
Sat Oct 5 02:07:41 UTC 2013


I'm trying to figure out how to write multiple values to an ID3v2.4 tag.
 ID3v2.4 spec is to have a single frame where all values are joined
together with a null character.  (By contrast, ID3v2.3 uses a backslash
instead of null.  XiphComment uses multiple frames instead of a single
frame with a delimiting character.)  I couldn't find any code examples for
ID3v2.4, so I tried two approaches which failed.

Approach 1:  add a new frame for each value
> // for each string {
> TagLib::ID3v2::TextIdentificationFrame *frame = new
TagLib::ID3v2::TextIdentificationFrame(keyStr, TagLib::String::UTF8);
> id3v2->addFrame(frame);
> frame->setText(str);
> // } close for loop
Result 1:  incorrect - multiple frames instead of a single frame.

Approach 2:  manually separate the values with the null character
> TagLib::StringList values;
> // { for each string, append the string to "values" }
> TagLib::ID3v2::TextIdentificationFrame *frame = new
TagLib::ID3v2::TextIdentificationFrame(keyStr, TagLib::String::UTF8);
> id3v2->addFrame(frame);
> frame->setText(values.toString('\0'));

Result 2: wrong and inconsistent behaviors:
- All values can be read by foobar2000
- The last value can't be read by Mp3tag, apparently because the text
encoding size is double what Mp3tag would write with the same input
- All values except the first can't be read by TagLib when the file is
opened again with code similar to https://gist.github.com/Horrendus/622816 .

I'm not sure if I'm using the null character correctly in Approach 2 given
how many apps it breaks (although foobar2000 handles it).   I'm hoping
there's an easy way to write multiple values to ID3v2.4 that I missed.
 What is the correct way to do this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20131004/84040af0/attachment.html>


More information about the taglib-devel mailing list