<div dir="ltr"><div>Why not use GetCommandLineW() and CommandLineToArgvW() on windows?<br><br></div>wmain is NOT implemented if you use MinGW.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/12/3  <span dir="ltr"><<a href="mailto:taglib-devel-request@kde.org" target="_blank">taglib-devel-request@kde.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send taglib-devel mailing list submissions to<br>
        <a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://mail.kde.org/mailman/listinfo/taglib-devel" target="_blank">https://mail.kde.org/mailman/listinfo/taglib-devel</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:taglib-devel-request@kde.org">taglib-devel-request@kde.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:taglib-devel-owner@kde.org">taglib-devel-owner@kde.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of taglib-devel digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. TagLib::FileRef and Unicode (Jeremy Gregorio)<br>
   2. Re: TagLib::FileRef and Unicode (Tsuda Kageyu)<br>
   3. Re: TagLib::FileRef and Unicode (Miyakoda Akira)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 2 Dec 2013 06:42:33 -0700<br>
From: Jeremy Gregorio <<a href="mailto:jeremy.firefox.addon@gmail.com">jeremy.firefox.addon@gmail.com</a>><br>
To: <a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a><br>
Subject: TagLib::FileRef and Unicode<br>
Message-ID:<br>
        <<a href="mailto:CAH2Gu2Ggtz5U7GTg7%2BW%2BnJdEvuVw01VX66rbhAwH-zbTn4M5wg@mail.gmail.com">CAH2Gu2Ggtz5U7GTg7+W+nJdEvuVw01VX66rbhAwH-zbTn4M5wg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hi all,<br>
      I finally noticed my little tagging program doesn't handle Unicode in<br>
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<br>
with Visual C++.<br>
<br>
      To deal with the headache that is passing Unicode Parameters I use<br>
URI Encoding (like here <a href="http://meyerweb.com/eric/tools/dencoder/" target="_blank">http://meyerweb.com/eric/tools/dencoder/</a>) to encode<br>
the parameters to a command line program I wrote and then decode them as<br>
they come in. This part seems to work since I can decode the strings and<br>
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 :(.<br>
Right no I'm using QT's library to handle the strings because of a<br>
stackoverflow post I found where the guy had good luck with it, but darned<br>
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<br>
text file and it looks right in notepad++ encoded in UTF-8 without the BOM.<br>
<br>
<br>
--<br>
Jeremy D Gregorio<br>
<br>
<<a href="http://www.linkedin.com/pub/jeremy-gregorio/36/302/429" target="_blank">http://www.linkedin.com/pub/jeremy-gregorio/36/302/429</a>><br>
<<a href="http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png" target="_blank">http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png</a>><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.kde.org/pipermail/taglib-devel/attachments/20131202/1d437d55/attachment-0001.html" target="_blank">http://mail.kde.org/pipermail/taglib-devel/attachments/20131202/1d437d55/attachment-0001.html</a>><br>

<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Tue, 03 Dec 2013 09:06:36 +0900<br>
From: Tsuda Kageyu <<a href="mailto:tsuda.kageyu@gmail.com">tsuda.kageyu@gmail.com</a>><br>
To: <a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a><br>
Subject: Re: TagLib::FileRef and Unicode<br>
Message-ID: <<a href="mailto:6CEEFBB882863tsuda.kageyu@gmail.com">6CEEFBB882863tsuda.kageyu@gmail.com</a>><br>
Content-Type: text/plain; charset=iso-8859-1<br>
<br>
Hi Jeremy.<br>
<br>
How about using wmain() instead of main()?<br>
main() is not suitable for arguments in Unicode. It converts the arguments into your local encoding irreversibly.<br>
<br>
This may help you:<br>
<br>
int wmain(int argc, wchar_t *argv[])<br>
{<br>
...<br>
    QString filepath = QString::fromWCharArray( argv[argc - 1] );<br>
<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Tue, 3 Dec 2013 09:16:33 +0900<br>
From: Miyakoda Akira <<a href="mailto:tsuda.kageyu@gmail.com">tsuda.kageyu@gmail.com</a>><br>
To: "<a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a>" <<a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a>><br>
Subject: Re: TagLib::FileRef and Unicode<br>
Message-ID:<br>
        <<a href="mailto:CAG4hMGekwX8Px%2B5hKiYNw-uUZ7xmkTtveQyzuBGgnq1LrTcubg@mail.gmail.com">CAG4hMGekwX8Px+5hKiYNw-uUZ7xmkTtveQyzuBGgnq1LrTcubg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Oh Jeremy! I forgot to tell you a thing.<br>
<br>
You should create a FileRef from a Unicode file name like this:<br>
<br>
int wmain(int argc, wchar_t *argv[])<br>
{<br>
...<br>
    QString filepath = QString::fromWCharArray( argv[argc - 1] );<br>
...<br>
    TagLib::FileRef f( filepath.toStdWString().cstr() );<br>
<br>
<br>
2013/12/2 Jeremy Gregorio <<a href="mailto:jeremy.firefox.addon@gmail.com">jeremy.firefox.addon@gmail.com</a>><br>
<br>
> Hi all,<br>
>       I finally noticed my little tagging program doesn't handle Unicode<br>
> 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<br>
> with Visual C++.<br>
><br>
>       To deal with the headache that is passing Unicode Parameters I use<br>
> URI Encoding (like here <a href="http://meyerweb.com/eric/tools/dencoder/" target="_blank">http://meyerweb.com/eric/tools/dencoder/</a>) to<br>
> encode the parameters to a command line program I wrote and then decode<br>
> them as they come in. This part seems to work since I can decode the<br>
> 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<br>
> :(. Right no I'm using QT's library to handle the strings because of a<br>
> stackoverflow post I found where the guy had good luck with it, but darned<br>
> 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<br>
> 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<br>
> text file and it looks right in notepad++ encoded in UTF-8 without the BOM.<br>
><br>
><br>
> --<br>
> Jeremy D Gregorio<br>
><br>
> <<a href="http://www.linkedin.com/pub/jeremy-gregorio/36/302/429" target="_blank">http://www.linkedin.com/pub/jeremy-gregorio/36/302/429</a>><br>
> <<a href="http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png" target="_blank">http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png</a>><br>
><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>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.kde.org/pipermail/taglib-devel/attachments/20131203/ebf46811/attachment-0001.html" target="_blank">http://mail.kde.org/pipermail/taglib-devel/attachments/20131203/ebf46811/attachment-0001.html</a>><br>

<br>
------------------------------<br>
<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>
<br>
End of taglib-devel Digest, Vol 114, Issue 1<br>
********************************************<br>
</blockquote></div><br></div>