Storing a UTF8 string fails with Cyrillic characters.
Scott Wheeler
wheeler at kde.org
Wed Jun 1 02:19:28 CEST 2005
On Tuesday 31 May 2005 23:11, Brian Nickel wrote:
> Hi,
>
> I'm writting a tagging plugin for the Muine Music Player (Gnome/C#)
> using TagLib. Everything is going well, and the library is beautiful
> to use, but I'm trying to get UTF8 strings to save as UTF8.
>
> One simple example:
>
> char * val = "Да, вы можете.";
> myTag->setTitle (TagLib::String(val, TagLib::String::UTF8));
> // myTag->title ().toCString (true) == "0, 2K <>65B5."
>
> Am I just doing something wrong, or is there another way to go about
> this, or is it a bug?
It's probably just an issue somewhere between unicode literals (i.e. did you
save the file as UTF-8 encoded?) the console's locale and whatnot. It should
work fine in real code -- that's the same method we use to convert things to
and from QString and it works quite well:
#define QStringToTString(s) TagLib::String(s.utf8().data(),
TagLib::String::UTF8)
(s.utf8().data() just returns a "const char *" of utf8 data)
Cheers,
-Scott
--
The three chief virtues of a programmer are: laziness, impatience and hubris.
--Larry Wall
More information about the taglib-devel
mailing list