how to select the encoding of the mp3 tag to read?

Scott Wheeler wheeler at kde.org
Mon Aug 30 18:55:22 CEST 2010


On Aug 29, 2010, at 2:37 PM, Anton Sergunov wrote:

>> I wonder if I could select the encoding of the mp3 tags I am to read.
>> Many mp3 here use encoding gb18030 (Chinese).
>
> Encoding stored in ID3v2 tag. So you dont need to set it manual.
> But ID3v1 all strings sould be stored in latin encoding. So old
> programs stores tag in local encoding. You can't know encoding, but in
> most cases old incorrected saved tags in local user encoding.
>
> My Qt solution:
>
> QString toQString(const TagLib::String& str)
> {
>  if(str.isLatin1())
>    return QString::fromLocal8Bit(str.to8Bit().c_str());
>  return QString::fromStdWString(str.toWString());
> }

The better way to do this is by subclassing ID3v1::StringHandler:

http://developer.kde.org/~wheeler/taglib/api/classTagLib_1_1ID3v1_1_1StringHandler.html

-Scott



More information about the taglib-devel mailing list