Bug 56169

Summary: wrong encoding on command line arguments
Product: [Unmaintained] kghostview Reporter: Choe Hwanjin <hjchoe>
Component: generalAssignee: Wilco Greven <greven>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Choe Hwanjin 2003-03-20 04:30:27 UTC
Version:            (using KDE KDE 3.1)
Installed from:    Compiled From Sources
Compiler:          gcc (GCC) 3.2 20020903 (HancomLinux 3.0 3.2-7hl) 
OS:          Linux

If I run kghostview on command line like below:

$ kghostview "some_korean_named_dir"/test.pdf

kghostview doesn't open "some_korean_named_dir"/test.pdf file.
I think this is a encoding problem.
While I applied a patch below,  that works fine.

--- kdegraphics-3.1/kghostview/main.cpp.orig	2003-03-20 12:08:20.000000000 +0900
+++ kdegraphics-3.1/kghostview/main.cpp	2003-03-20 12:26:54.000000000 +0900
@@ -50,10 +50,10 @@
 	    } else {
                 QFileInfo fi = QDir::current().absPath() +
                                QDir::separator() +
-                               args->arg(0);
+                               QString::fromLocal8Bit(args->arg(0));
 		if (fi.exists())
 			shell->openURL( KURL::fromPathOrURL( fi.absFilePath() ) );
-		else shell->openURL( KURL::fromPathOrURL( args->arg(0) ));
+		else shell->openURL( KURL::fromPathOrURL( QString::fromLocal8Bit(args->arg(0)) ));
 	    }
 	}
 	shell->show();
Comment 1 Thiago Macieira 2003-03-20 16:02:26 UTC
Agreed. KCmdLineArgs::args(int) returns const char*. One should ALWAYS use one 
of QString's encoding functions on those, not allow default conversion. 
Comment 2 Luís Pedro Coelho 2003-04-03 23:18:33 UTC
This is partially my fault.  
It has been fixed in HEAD, but it needs backporting which I will do right away. 
 
luis pedro coelho 
Comment 3 Luís Pedro Coelho 2003-04-03 23:49:58 UTC
I am committing to BRANCH the same main.cpp as HEAD, as I think it will fix this 
bug and it is simpler code. 
 
I was able to reproduce it on BRANCH using UTF-8 encoded dir-names and after 
this patch it seems to work. 
 
Thanks for reporting the bug, 
luis pedro coelho 
Comment 4 Luís Pedro Coelho 2003-04-03 23:52:17 UTC
Subject: KDE_3_1_BRANCH: kdegraphics/kghostview

CVS commit by luis_pedro: 

Backport of right argument parsing.
Also backports new address of FSF.

CCMAIL: 56169-done@bugs.kde.org


  M +3 -7      main.cpp   1.54.2.2


--- kdegraphics/kghostview/main.cpp  #1.54.2.1:1.54.2.2
@@ -14,5 +14,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
@@ -49,10 +49,5 @@ int main( int argc, char** argv )
                 shell->openStdin();
             } else {
-                QFileInfo fi = QDir::current().absPath() +
-                               QDir::separator() +
-                               args->arg(0);
-                if (fi.exists())
-                        shell->openURL( KURL::fromPathOrURL( fi.absFilePath() ) );
-                else shell->openURL( KURL::fromPathOrURL( args->arg(0) ));
+                shell->openURL( args->url(0) );
             }
         }