Newbie C question #2, TagLib, Firefox & Unicode
Jeremy Gregorio
jeremy.firefox.addon at gmail.com
Sun Feb 6 20:31:19 CET 2011
Hi again :). So I can now tag MP3s from my plugin, youtubemp3podcaster (
https://addons.mozilla.org/en-US/firefox/addon/youtube-mp3-podcaster/). But
I'm struggling with Unicode. I wrote a function to handle the tagging, the
prototype is like so:
NS_IMETHODIMP MyComponent::Tag(const PRUnichar *path, const PRUnichar
*title, const PRUnichar *artist, const PRUnichar *album, const PRUnichar
*comment, const PRUnichar *genre, const PRUnichar *year, const PRUnichar
*track)
I'm building under Windows, so as near as I can tell from here:
https://developer.mozilla.org/En/PRUnichar
the PRUnichars are just wchar_t points, which if I understand right is just
UTF16 encoded strings. Here's how the docs say PRUnichar is defined:
#if defined(NS_WIN32)
typedef wchar_t PRUnichar;
#else
typedef PRUInt16 PRUnichar;
#endif
I was hoping I could just do :
TagLib::FileRef f (path);
but that blows up with a memory error, I think because FileRef expects a
simple pointer to char and I'm trying to send in a PRUnichar. So then I
tried to build a TagLib::String object hoping to pass it to FileRef, like
so:
TagLib::String myFileName( (wchar_t*) path, TagLib::String::UTF16 );
But that crashes too. At any rate, now that I look at the class definition
for FileRef I don't know why doing
TagLib::FileRef f (path);
Works if I'm just using char*, because I don't see a constructor that takes
a char*.
If I have too I can use native types instead of PRUnichar, but it'd be nice
if I could use it since it'll make the Linux & Mac OSX ports much easier.
I know TagLib supports Unicode, but I can't figure out what I'm doing wrong.
Am I just casting to the wrong types or is it more complex?
Thanks again!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/taglib-devel/attachments/20110206/8e216185/attachment.htm
More information about the taglib-devel
mailing list