From kde-commits Sun Apr 04 17:55:19 2004 From: Scott Wheeler Date: Sun, 04 Apr 2004 17:55:19 +0000 To: kde-commits Subject: Re: kdesupport/taglib/mpeg/id3v1 Message-Id: <200404041955.26532.wheeler () kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=108110142100828 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_HwEcA2dkGPsxEDk" --Boundary-00=_HwEcA2dkGPsxEDk Content-Type: Text/Plain; charset="us-ascii"; boundary="" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ok, and now I'm attaching a small Qt-based program that shows how to overri= de=20 the default string encoding. This one just uses utf8, but I think it's cle= ar=20 how one would proceed based on this... I would also recommend by default (i.e. when ISO-8859-1 is selected) not us= ing=20 an external string handler at all since they extra lookups will likely slow= =20 things down... =2D -Scott On Sunday 04 April 2004 16:42, Scott Wheeler wrote: > CVS commit by wheeler:=20 >=20 > Add the ability to override the default ID3v1 string handling in TagLib by > adding a ID3v1::StringHandler class that has render and parse methods. >=20 > By default this still makes the (correct) assumption that ID3v1 tags cont= ain > ISO-8859-1 data, but this makes it easy for applications to override this= to > allow user specified codecs. >=20 > CCMAIL:78428@bugs.kde.org > CCMAIL:77710@bugs.kde.org > CCMAIL:amarok-devel@lists.sourceforge.net > CCMAIL:Shlomi Loubaton > CCMAIL:Nir Misgav >=20 >=20 > M +34 -10 id3v1tag.cpp 1.23 > M +47 -0 id3v1tag.h 1.14 >=20 >=20 >=20 >=20 =2D --=20 Many people would sooner die than think; in fact, they do so.=20 =2D --Bertrand Russell =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQFAcEwKQu0ByfY5QTkRAkJ6AKDNP3i9PIzwkm8yBYBRJV+vih9HNwCgoIvL /497A6rVnHUkyYD51Yf3kfI=3D =3DmLTy =2D----END PGP SIGNATURE----- --Boundary-00=_HwEcA2dkGPsxEDk Content-Type: text/x-c++src; charset="us-ascii"; name="utf8.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="utf8.cpp" // g++ `taglib-config --libs --cflags` -I${QTDIR}/include -L${QTDIR}/lib -Wl,-R${QTDIR}/lib -lqt-mt utf8.cpp -o utf8 #include #include #include #include #include using namespace TagLib; class LocaleStringHandler : public ID3v1::StringHandler { public: LocaleStringHandler() : m_codec(QTextCodec::codecForName("utf8")) {} virtual String parse(const ByteVector &data) const { return QStringToTString(m_codec->toUnicode(data.data(), data.size())); } private: QTextCodec *m_codec; }; int main(int argc, char *argv[]) { ID3v1::Tag::setStringHandler(new LocaleStringHandler); for(int i = 1; i < argc; i++) { TagLib::MPEG::File f(argv[i], false); if(f.isValid() && f.ID3v1Tag(false)) { Tag *tag = f.ID3v1Tag(false); cout << "title - \"" << tag->title() << "\"" << endl; cout << "artist - \"" << tag->artist() << "\"" << endl; cout << "album - \"" << tag->album() << "\"" << endl; cout << "year - \"" << tag->year() << "\"" << endl; cout << "comment - \"" << tag->comment() << "\"" << endl; cout << "track - \"" << tag->track() << "\"" << endl; cout << "genre - \"" << tag->genre() << "\"" << endl; } } } --Boundary-00=_HwEcA2dkGPsxEDk--