Bug 136590

Summary: problem with cyrillic's filenames: cannot open file
Product: [Unmaintained] kfax Reporter: Boris <d9tetra>
Component: generalAssignee: Bernd Wuebben <wuebben>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Boris 2006-10-31 21:24:07 UTC
Version:           3.3.1 (using KDE 3.3.2,  (3.1))
Compiler:          gcc version 3.3.5 (Debian 1:3.3.5-13)
OS:                Linux (i686) release 2.6.16-1-686

I've got error "Cannot open file /home/user/fax/????.tif" when I try open a file with Cyrillic's chars in filename:
user$ ls
тест.tif
user$ locale
LANG=ru_RU.KOI8-R
LC_ALL=ru_RU.KOI8-R
user$ kfax /home/user/тест.tif
TIFFOpen: /home/user/????.tif: Cannot open.
Comment 1 Martin Koller 2006-11-12 19:29:30 UTC
SVN commit 604390 by mkoller:

BUG: 136590

Fix handling of filenames with non-ascii chars



 M  +7 -6      faxinput.cpp  
 M  +2 -2      kfax.cpp  
 M  +1 -1      viewfax.cpp  


--- branches/KDE/3.5/kdegraphics/kfax/faxinput.cpp #604389:604390
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include "faxexpand.h"
 #include <qstring.h>
+#include <qfile.h>
 #include <kapplication.h>
 #include <klocale.h>
 #include <kdebug.h>
@@ -109,7 +110,7 @@
 
 
     if ((tf = fopen(name, "r")) == NULL) {
-        QString mesg = i18n("Unable to open:\n%1\n").arg(name);
+        QString mesg = i18n("Unable to open:\n%1\n").arg(QFile::decodeName(name));
 	kfaxerror(i18n("Sorry"), mesg);
 	return 0;
     }
@@ -146,7 +147,7 @@
 
 	if (fseek(tf, IFDoff, SEEK_SET) < 0) {
 	realbad:
-	  str = i18n("Invalid tiff file:\n%1\n").arg(name);
+	  str = i18n("Invalid tiff file:\n%1\n").arg(QFile::decodeName(name));
 	  kfaxerror(i18n("Sorry"),str);
 	bad:
 	    if (strips)
@@ -248,7 +249,7 @@
 	    case 279:		/* StripByteCounts */
 		if (count != nstrips) {
 		  str = i18n("In file %1\nStripsPerImage tag 273=%2,tag279=%3\n")
-			      .arg(name).arg(nstrips).arg(count);
+			      .arg(QFile::decodeName(name)).arg(nstrips).arg(count);
 		  kfaxerror(i18n("Message"),str);
 		  goto realbad;
 		}
@@ -418,7 +419,7 @@
 	pn->length = pn->strips[strip].size;
     }
     else {
-      str = i18n("Trying to expand too many strips\n%1%n").arg(pn->pathname);
+      str = i18n("Trying to expand too many strips\n%1%n").arg(QFile::decodeName(pn->pathname));
       kfaxerror(i18n("Warning"),str);
       return NULL;
     }
@@ -447,7 +448,7 @@
 	/* handle ghostscript / PC Research fax file */
       if (Data[24] != 1 || Data[25] != 0){
 	str = i18n("Only the first page of the PC Research multipage file\n%1\nwill be shown\n")
-		.arg(pn->pathname);
+		.arg(QFile::decodeName(pn->pathname));
 	kfaxerror(i18n("Message"),str);
       }
 	pn->length -= 64;
@@ -461,7 +462,7 @@
 	pn->height = G3count(pn, pn->expander == g32expand);
     if (pn->height == 0) {
 
-      str = i18n("No fax found in file:\n%1\n").arg(pn->pathname);
+      str = i18n("No fax found in file:\n%1\n").arg(QFile::decodeName(pn->pathname));
       kfaxerror(i18n("Sorry"),str);
       errno = 0;
       badfile(pn);
--- branches/KDE/3.5/kdegraphics/kfax/kfax.cpp #604389:604390
@@ -540,7 +540,7 @@
 {
   auxpage = lastpage;
 
-  loadfile(QFile::encodeName(filename));
+  loadfile(filename);
 
   if( firstpage != lastpage )
   {
@@ -1355,7 +1355,7 @@
 
   Image =  Images[0] = Pimage(thispage);
 
-  setCaption(thispage->name);
+  setCaption(QFile::decodeName(thispage->name));
 
   Image = generateZoomImages(oz);
   
--- branches/KDE/3.5/kdegraphics/kfax/viewfax.cpp #604389:604390
@@ -240,7 +240,7 @@
     firstpage = lastpage = thispage = helppage = auxpage =  0;
 
     for (int i = 0; i < args->count(); i++){
-	loadfile(args->arg(i));
+	loadfile(QFile::decodeName(args->arg(i)));
     }
     args->clear();