Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to correctly store list of items as APEv2 tag? (Read 1414 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to correctly store list of items as APEv2 tag?

Hi there,
i use wavpack as compressor for my audio projects and i would like to use APEv2 tags to store additional information.
Somewhere i found, that APEv2 is suitable for UTF8 strings, binary data and list of items. However, i could not find a definitive answer on how to "serialize" a list of items or how to separate them.
Is it: "item1, item2, item3" // separated by comma and space?
or is it: "item1\\item2\\item3" // separated by double backslash?
or something else? // I read somehting about zero character?

Any hints welcome.

Thanks in advance.

Re: How to correctly store list of items as APEv2 tag?

Reply #1
I assume you're talking about multiple values for a single item, for example "Artist" consisting of "Borodin String Quartet, Sviatoslav Richter (Piano)". The APEv2 spec dictates that these are accomplished with, as you say, NULL characters (i.e., zero) as separators. As a C programmer, I don't care for this because native C strings can't have embedded NULLs, and this makes everything more complicated than it needs to be, but there it is. And my understanding is that Vorbis tags and ID3v2.4 (and ID3v2.3 unofficially) also adhere to this.

So, the WavPack library allows for this. The APIs for reading and writing tags allow for embedded NULLs. So programs using libwavpack to create or read APEv2 tags can properly handle multiple values for an item. However, there's no universal way to display or input a NULL character, so user-facing applications have to do that however they see fit (e.g., with "/" or "\" or newline or whatever). And note that many applications (like Foobar2000) have their own libraries for manipulating APEv2 tags, but it would be assumed that they handled the NULLs the same.

The WavPack command-line tools have very limited support for this. The programs wvunpack or wvtag will display the embedded NULLs in tags values as "\", but there is no way to create such tags from the command-line. To handle ID3v2.4 tags I recently created a function to "append" a tag item to an existing tag (will NULL separator, and assuming that string was not already present in the value), so maybe a way to accomplish this would be to create a new option ("-ww"?) that would append to an existing tag.

Anyway, I hope this answer is what you were looking for.

Re: How to correctly store list of items as APEv2 tag?

Reply #2
Yes, this answers my question pretty much and detailed.

I completely agree with you, that using a zero character as separator is just as useful as a hole in the head.

Since I am developing using C++ and std::string can actually carry binary data, this should not be a big issue, though.

Thanks a lot for your input.

 

Re: How to correctly store list of items as APEv2 tag?

Reply #3
Glad I could help!

I recently went through this in C++ for the WavPack handling code in Audacity. In case they might be useful I will post the snippets that import and export tags from WavPack using libwavpack. Audacity uses wxStrings internally, but this code uses std::strings as an intermediary. The one bug I had a little trouble with is that the original code was creating std::strings with terminating NULLs because libwavpack insists on NULL terminating the strings it returns (or it will truncate the value). This is of course allowed in std::strings but obviously they are not going to match the same string without the NULL, and are just wrong. The whole thing is a little confusing and a bit of a mess, but it works reliably now...   :)

WavPack tag import code in Audacity

WavPack tag export code in Audacity