Issues with unicode conversion

Ali Shah caffein at
Fri Aug 17 09:44:41 CEST 2007

Hi, I have some weird issues with trying to retrieve tags in unicode,
while using taglib 1.4.
I am trying to retrieve the album name, the track title and the artist
(in this specific order)
from a tag in utf-8 format. Unfortunately if I extract the tag like the
example below, the title sanity check's end up being garbage for some
tracks, and perfect for others. For example the current setup seems to
work with UTF-8 tags, where as they fail for normal ascii Tags..
What am i doing wrong? I've been trying to work out the issues all
nigth and I am completely at a loss. 

/*** Copy the album */
    const char* actualAlbum =
    if (tagFile.tag()->album() == TagLib::String(""))
        actualAlbum= unknownString.toCString(true);
    char* album = strdup(actualAlbum); 
    QString qalbum1 = QString::fromUtf8(actualAlbum);
    QString qalbum2 = QString::fromUtf8(album);

    qDebug() << "Album sanity check1: " << qalbum1;
    qDebug() << "Album sanity check2: " << qalbum2; 

/*** Copy the title */
    const char* actualTitle =
    if (tagFile.tag()->title() == TagLib::String(""))
        actualTitle= unknownString.toCString(true);
    char* title = strdup(actualTitle);
    QString qtitle1= QString::fromUtf8(actualTitle);
    QString qtitle2 = QString::fromUtf8(title);

    qDebug() << "Title sanity check1: " << qtitle1;
    qDebug() << "Title sanity check2: " << qtitle2;

/*** Copy the artist */
    const char* actualArtist =
    if (tagFile.tag()->artist() == TagLib::String(""))
        actualArtist= unknownString.toCString(true);
    char* artist = strdup(actualArtist); 
    QString qartist1= QString::fromUtf8(actualArtist);
    QString qartist2 = QString::fromUtf8(artist);

    qDebug() << "Artist sanity check1: " << qartist1;
    qDebug() << "Artist sanity check2: " << qartist2;


More information about the taglib-devel mailing list