Unicode FileRef Instantiation

Zach Rattner zach.rattner at gmail.com
Mon Jan 25 03:08:00 CET 2010


Hi,

I'm using TagLib on one of my projects (using Qt 4.5), and I'm having some
trouble with foreign character support. I have a couple mp3 files with
non-ASCII characters in the file path (mainly just accented vowels). Based
on the TagLib::FileRef API, it appears as though the only way to create a
file reference from a path is with a char *. Is there any way I can use a
Unicode string to pass in the filename?

The issue I'm encountering is best illustrated as follows:
TagLib::FileRef File(p_FilePath.toStdString().c_str()); // Compiles and
works, but breaks down if filename has non-ASCII characters
TagLib::FileRef File(p_FilePath.toStdWString());        // Doesn't compile

The Qt documentation of toStdWString can be found at the following address:
http://doc.trolltech.com/4.6/qstring.html#toStdWString

Here's an example that works, going in the opposite direction (loading
Unicode data from an existing reference):
QString Title  = QString::fromStdWString(File.tag()->title().toWString());

I would appreciate any clarification you are able to give. It's entirely
possible I'm just not using the class properly. Apart from this issue, I'm
thoroughly impressed with TagLib. Good work!

Thanks,
Zach Rattner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/taglib-devel/attachments/20100124/666c1b1f/attachment.htm 


More information about the taglib-devel mailing list