<div dir="ltr"><div><div><div>Thanks! That did the trick. I'm passing in url encoded file names, so I do this:<br><br>int wmain(int argc, wchar_t *argv[])<br>{<br><br> TagLib::List<TagLib::FileRef> fileList;<br>
QString filepath = QString::fromWCharArray ( argv[argc - 1] );<br> QString url = QUrl::fromPercentEncoding( filepath.toLocal8Bit() );<br> TagLib::FileRef f( url.toStdWString().c_str() );<br><br>...<br><br></div>
which gets me a working Taglib::Fileref. :). <br><br></div>From here I can decode the rest of my parameters using<br><br>...<br> QString decoded = QString::fromWCharArray ( argv[i + 1] );<br> QString qValue = QUrl::fromPercentEncoding( decoded.toLocal8Bit() );<br>
TagLib::String value ( qValue.toUtf8().constData(), TagLib::String::UTF8);<br>...<br><br></div>I ran across QStringToTString, but it seem broken since QT 4.8 uses constData() instead of data(), but it was just as easy to re-write the template :). This'll help a lot, since it should (finally) fix the handling of unicode paths in my app.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 2, 2013 at 5:16 PM, Miyakoda Akira <span dir="ltr"><<a href="mailto:tsuda.kageyu@gmail.com" target="_blank">tsuda.kageyu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Oh Jeremy! I forgot to tell you a thing.</div><div><br></div><div>You should create a FileRef from a Unicode file name like this:</div>
<div class="im"><div><br></div><div>int wmain(int argc, wchar_t *argv[])</div><div>
{</div><div>...</div></div><div> QString filepath = QString::fromWCharArray( argv[argc - 1] );</div><div>...</div><div> TagLib::FileRef f( filepath.toStdWString().cstr() );</div></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">
2013/12/2 Jeremy Gregorio <span dir="ltr"><<a href="mailto:jeremy.firefox.addon@gmail.com" target="_blank">jeremy.firefox.addon@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
<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/" target="_blank">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.<span><font color="#888888"><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></a><br><a href="http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png" target="_blank"></a>
</font></span></div>
<br></div></div><div class="im">_______________________________________________<br>
taglib-devel mailing list<br>
<a href="mailto:taglib-devel@kde.org" target="_blank">taglib-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/taglib-devel" target="_blank">https://mail.kde.org/mailman/listinfo/taglib-devel</a><br>
<br></div></blockquote></div><br></div>
<br>_______________________________________________<br>
taglib-devel mailing list<br>
<a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/taglib-devel" target="_blank">https://mail.kde.org/mailman/listinfo/taglib-devel</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Jeremy D Gregorio<br>Sr Consultant<br>#: 520-275-5352<br>fax: 520-747-2540<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>