kcmdlineargs input decoding

David Faure faure at kde.org
Wed Feb 25 17:50:38 GMT 2009


On Wednesday 25 February 2009, Nick Shaforostoff wrote:
> Hi. Opening files with non-ASCII names via cmd line in any KDE app
> isn't possible on my system,
> as args are misencoded due to QString::fromLocal8Bit() returning
> different data before and after QApplication creation.
> 
> Attached patch fixes the issue by delaying conversion and moving it to
> KCmdLineArgs::arg(),
> as a side affect it switches KCmdLineArgs args processing to use
> QByteArray internaly,
> which is a little bit more memory efficient.

Very interesting. Good patch IMHO.

FWIW the attached patch fixes the issue too (qt-copy-trunk required, unpatched rc1
doesn't have the necessary exported symbol).

@@ -263,8 +264,10 @@                                                                              
     mStdargs = 0;                                                                                
                                                                                                  
     // Text codec.                                                                               
+    setlocale(LC_ALL, ""); // need to initialize "System" codec, i.e. iconv                      
+    extern Q_CORE_EXPORT bool qt_locale_initialized;                                             
+    qt_locale_initialized = true;                                                                
     codec = QTextCodec::codecForLocale();                                                        
-    setlocale(LC_ALL, ""); // need to initialize "System" codec, i.e. iconv                      
                                                                                                  
     // Qt options
     //FIXME: Check if other options are specific to Qt/X11

But if you found a way to delay all the locale8bit conversions, that's even better.
Please commit (to trunk).

-- 
David Faure, faure at kde.org, sponsored by Qt Software @ Nokia to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list