more-taglib-examples/taglib-set-picture.cpp on Visual Studio 2008

Sven Grunewaldt strayer at olle-orks.org
Wed Nov 5 11:02:31 CET 2008


Sven Grunewaldt schrieb:
> Hello,
>
> I'm trying to build a little program which embeds folder.jpg's into all
> MP3s in the same folder.
> I already compiled taglib and successfully compiled the
> tagreader.cpp-Example.
>
> The next step I took was to build the source of this example:
> http://developer.kde.org/~wheeler/files/more-taglib-examples/taglib-set-picture.cpp
>
> Sadly, I get the following error:
> error C2440: 'Initialisierung': 'TagLib::FileName' kann nicht in
> 'TagLib::String' konvertiert werden
> ('TagLib::FileName' could not be converted to 'TagLib::String', Line 50)
>
> I'm currently a little bit confused and don't know what to do next...
>
> I use Visual Studio 2008 on Windows Vista 32bit.
>
> Greetings,
> Sven Grunewaldt
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>   
Okay, I asked my colleagues for a little help and I got it solved now,
but I think I found a bug.

While debugging I changed the mimeType function to this:
    TagLib::String mimeType() const
    {
        TagLib::String fileName = (const char*) this->name();
        unsigned int length = fileName.length();
        TagLib::String fileExt4 = fileName.substr(length - 4, 4);
        TagLib::String fileExt5 = fileName.substr(length - 5, 5);
        fileExt4 = fileExt4.upper();
        fileExt5 = fileExt5.upper();

        if(fileExt4 == ".PNG")
            return "image/png";
        else if(fileExt4 == ".JPG" ||
                fileExt5 == ".JPEG")
            return "image/jpeg";
        else
            return TagLib::String::null;
    }
This code finally works and I got the picture attached!

Now to the bug thing... when I change the third line from (const char*)
to (const wchar_t*) the returned string is empty.
Maybe I got this wrong.. but shouldn't wchar_t just be the same as the
char but in unicode?

Greetings,
Sven Grunewaldt


More information about the taglib-devel mailing list