[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglib-devel
Subject:    utf8 tag processing
From:       Ray <whatdoineed2do () yahoo ! co ! uk>
Date:       2007-01-17 0:51:01
Message-ID: 465037.75649.qm () web23307 ! mail ! ird ! yahoo ! com
[Download RAW message or body]

hi folks,

i think am a little off topic but i've kinda run out
of ideas of my own; i am writing a cmd line tool to
tag mp3s with utf8 unicode strings using taglib.

however i've run into a problem whereby if the unicode
string from argv[] always seem to get messed up
however, if i use the same static string within the
code, it can be encoded and retrieved from the tag
fine.  even if the static string and the input are the
same (as shown by memcmp) the results of getting the
data back is still wrong.

my terminal has LANG="en_US.utf8"

can anyone point me at where i am going wrong?
thanks
ray


#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include <iostream>

#include <fileref.h>
#include <tfile.h>
#include <tag.h>
#include <id3v2tag.h>

using namespace std;

int main(int argc, char *argv[])
{
    const char* const  data = "&#38518;&#21894;";

    setlocale(LC_ALL, "en_US.utf8");

    const size_t  b = strlen(data);
    TagLib::ID3v2::Tag  t;

    t.setArtist(TagLib::String(data,
TagLib::String::UTF8));
    cout << "original utf8='" << data << "', as
(latin) cstr='" << t.artist().toCString() << "', as
(unicode) cstr='" << t.artist().toCString(true) << "'"
<< endl;

    if (argc == 2) {
	if (strlen(argv[1]) == b && memcmp(data, argv[1], b)
== 0) {
	    cout << "input and static data are the same" <<
endl;
	}

	t.setComment(TagLib::String(argv[1],
TagLib::String::UTF8));
	cout << "original utf8='" << argv[1] << "', as
(latin) cstr='" << t.comment().toCString() << "', as
(unicode) cstr='" << t.comment().toCString(true) <<
"'" << endl;
    }
}


		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security \
Centre. http://uk.security.yahoo.com _______________________________________________
taglib-devel mailing list
taglib-devel@kde.org
https://mail.kde.org/mailman/listinfo/taglib-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic