Newbie C question #2, TagLib, Firefox & Unicode

Jeremy Gregorio jeremy.firefox.addon at gmail.com
Mon Feb 7 00:45:12 CET 2011


Hi,
Thanks for the reply :D. The string is definitely getting mangled. I'm
missing something. I tried creating a TagLib::wstring with my path string
like so:

TagLib::wstring myFileNameWString ( (wchar_t*) path, TagLib::String::UTF16
);

and got gibberish.

I finally noticed that the TagLib::String class stores everything as
UTF16BE. My PRUnichar* is really a wchar_t*, which is UTF16 (I think :) ).

I'm still a little confused on how the TagLib::String class works. In the
constructor:

TagLib::String::String (const wchar_t * s, Type t = UTF16BE)

What is the second parameter for? At first I thought it was the encoding for
the first parameter, but reading the docs that isn't so...

If I understand right, I need to convert my strings from UTF16 encoded
wchar_t to UTF16BE before I try to use them with the TagLib::String
constructor. Is that right? If it is, is there an easy way to do that, or do
I have to dig into the specs for the two encodings?

Thanks again!

On Sun, Feb 6, 2011 at 12:58 PM, Jim <jmartin92 at comcast.net> wrote:

> On 2/6/2011 2:31 PM, Jeremy Gregorio wrote:
> > 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:
> >
> > 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*.
> >
>
> At first glance, I can't tell you why using a TagLib String would cause a
> crash.
>  Have you tried looking at the string after conversion?
>
> However, I can tell you why using a char* works.
>
> Here's the constructor:
>
> FileRef (FileName fileName, bool readAudioProperties=true,
> AudioProperties::ReadStyle audioPropertiesStyle=AudioProperties::Average)
>
> FileName is a const char*.  So that's the constructor you are calling with
> the
> default values.
>
> Jim
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/taglib-devel/attachments/20110206/e52335d9/attachment.htm 


More information about the taglib-devel mailing list