[prev in list] [next in list] [prev in thread] [next in thread]
List: taglib-devel
Subject: TagLib::FileRef and Unicode
From: Jeremy Gregorio <jeremy.firefox.addon () gmail ! com>
Date: 2013-12-02 13:42:33
Message-ID: CAH2Gu2Ggtz5U7GTg7+W+nJdEvuVw01VX66rbhAwH-zbTn4M5wg () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi all,
I finally noticed my little tagging program doesn't handle Unicode in
the slightest :).
Does anyone have suggestions on handling Unicode files?
I'm on an English (United States) Windows XP install trying to build
with Visual C++.
To deal with the headache that is passing Unicode Parameters I use
URI Encoding (like here http://meyerweb.com/eric/tools/dencoder/) to encode
the parameters to a command line program I wrote and then decode them as
they come in. This part seems to work since I can decode the strings and
write them to tags with the Unicode intact.
But when I try to write tags to a file on a Unicode path it fails :(.
Right no I'm using QT's library to handle the strings because of a
stackoverflow post I found where the guy had good luck with it, but darned
if I can get it working.
int main(int argc, char *argv[])
{
TagLib::List<TagLib::FileRef> fileList;
std::string fileName( "c:\\temp\\debug " );
std::string extension (".txt");
ofstream a_file ( fileName + extension );
QString filepath ( argv[argc - 1] );
QString url = QUrl::fromPercentEncoding( filepath.toUtf8() );
a_file << "Param: " << url.toStdString() << "\n\n";
QFile myQfile ( url );
if( !myQfile.exists() ){
a_file << "The param \"" << myQfile.error() << "\" is not a file.";
}//END IF
TagLib::FileRef f( QFile::encodeName(url).constData() );
if(!f.isNull() && f.tag())
fileList.append(f);
argc--;
a_file.close();
//... If I get this far I can start applying tags.
The above works great until I try it with a unicode path, like
"C:\temp\?\Power Up!.mp3"
which I encode as
C%3A%5Ctemp%5C%E7%A7%81%5CPower%20Up!.mp3
I know I'm at least getting the string decoded right since I write it to a
text file and it looks right in notepad++ encoded in UTF-8 without the BOM.
--
Jeremy D Gregorio
<http://www.linkedin.com/pub/jeremy-gregorio/36/302/429>
<http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png>
[Attachment #5 (text/html)]
<div dir="ltr">Hi all,<br> I finally noticed my little tagging program \
doesn't handle Unicode in the slightest :).<br><br> Does anyone have \
suggestions on handling Unicode files?<br><br> I'm on an English (United \
States) Windows XP install trying to build with Visual C++.<br> <br> To deal \
with the headache that is passing Unicode Parameters I use URI Encoding (like here <a \
href="http://meyerweb.com/eric/tools/dencoder/">http://meyerweb.com/eric/tools/dencoder/</a>) \
to encode the parameters to a command line program I wrote and then decode them as \
they come in. This part seems to work since I can decode the strings and write them \
to tags with the Unicode intact.<br> <br> But when I try to write tags to a file \
on a Unicode path it fails :(. Right no I'm using QT's library to handle the \
strings because of a stackoverflow post I found where the guy had good luck with it, \
but darned if I can get it working.<br> <br>int main(int argc, char \
*argv[])<br>{<br><br> TagLib::List<TagLib::FileRef> fileList;<br><br> \
std::string fileName( "c:\\temp\\debug " );<br> std::string extension \
(".txt");<br> ofstream a_file ( fileName + extension );<br> <br> \
QString filepath ( argv[argc - 1] );<br> <br> QString url = \
QUrl::fromPercentEncoding( filepath.toUtf8() );<br><br> a_file << \
"Param: " << url.toStdString() << "\n\n";<br> <br> \
QFile myQfile ( url );<br><br> if( !myQfile.exists() ){<br> a_file << \
"The param \"" << myQfile.error() << "\" is not \
a file.";<br> }//END IF<br><br> TagLib::FileRef f( \
QFile::encodeName(url).constData() );<br> <br> if(!f.isNull() && \
f.tag())<br> fileList.append(f);<br><br> argc--;<br><br> a_file.close();<br> \
<br> //... If I get this far I can start applying tags.<br><br> The above works \
great until I try it with a unicode path, like<br> <br>"C:\temp\?\Power \
Up!.mp3"<br><br>which I encode \
as<br><br>C%3A%5Ctemp%5C%E7%A7%81%5CPower%20Up!.mp3<br><br>I know I'm at least \
getting the string decoded right since I write it to a text file and it looks right \
in notepad++ encoded in UTF-8 without the BOM.<br> <br clear="all"><br>-- <br>Jeremy \
D Gregorio<br><br><a href="http://www.linkedin.com/pub/jeremy-gregorio/36/302/429" \
target="_blank"><img \
src="http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png"></a><br><a \
href="http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png" \
target="_blank"></a> </div>
_______________________________________________
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