Bug 123495 - Can't load the file which path name includes Chinese
Summary: Can't load the file which path name includes Chinese
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (other bugs)
Version First Reported In: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Cyrille Berger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-12 14:33 UTC by younker
Modified: 2017-02-05 17:01 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description younker 2006-03-12 14:33:58 UTC
Version:           1.4.95 (using KDE KDE 3.5.1)
Installed from:    Gentoo Packages
Compiler:          gcc 4.1.0 
OS:                Linux

Load a image file from Win32 Fat partition, it said 
"Could not open
/mnt/Pictures/My Photos/02_Disc/苏州/pict7539.jpg.
Reason: Cannot create storage", but the image can be shown in the preview panel.

System locale: zh_CN.UTF-8
Comment 1 Halla Rempt 2006-03-12 14:41:22 UTC
Ah, yes I can confirm.
Comment 2 Halla Rempt 2006-03-12 14:48:13 UTC
This is a problem with the tif and jpeg filters, not the magick filter, so it must be a bug in tif and jpeg. Cyrille, can you look at it? Reproducing is easy. Just open kcharselect, goto page 99, select any chinese character, copy it to the clipboard, and then type use that to copy the file to a file with a hanzi name. Opening in Krita gives exactly the error described.
Comment 3 Cyrille Berger 2006-03-13 19:32:38 UTC
SVN commit 518325 by berger:

fix loading of jpeg, tiff and png with a chinese character (or any other utf8) in the name. (and fix saving as an extra free bonus)

BUG:123495


 M  +4 -2      jpeg/kis_jpeg_converter.cc  
 M  +4 -2      png/kis_png_converter.cc  
 M  +4 -2      tiff/kis_tiff_converter.cc  


--- trunk/koffice/filters/krita/jpeg/kis_jpeg_converter.cc #518324:518325
@@ -25,6 +25,8 @@
 #include <iccjpeg.h>
 }
 
+#include <qfile.h>
+
 #include <kapplication.h>
 #include <KoDocumentInfo.h>
 
@@ -108,7 +110,7 @@
     jpeg_create_decompress(&cinfo);
     
     // open the file
-    FILE *fp = fopen(uri.path().ascii(), "rb");
+    FILE *fp = fopen(QFile::encodeName(uri.path()), "rb");
     if (!fp)
     {
         return (KisImageBuilder_RESULT_NOT_EXIST);
@@ -358,7 +360,7 @@
     if (!uri.isLocalFile())
         return KisImageBuilder_RESULT_NOT_LOCAL;
     // Open file for writing
-    FILE *fp = fopen(uri.path().ascii(), "wb");
+    FILE *fp = fopen(QFile::encodeName(uri.path()), "wb");
     if (!fp)
     {
         return (KisImageBuilder_RESULT_FAILURE);
--- trunk/koffice/filters/krita/png/kis_png_converter.cc #518324:518325
@@ -22,6 +22,8 @@
 
 #include <stdio.h>
 
+#include <qfile.h>
+
 #include <kapplication.h>
 #include <KoDocumentInfo.h>
 
@@ -120,7 +122,7 @@
 {
     kdDebug(41008) << "Start decoding PNG File" << endl;
     // open the file
-    FILE *fp = fopen(uri.path().ascii(), "rb");
+    FILE *fp = fopen(QFile::encodeName(uri.path()), "rb");
     if (!fp)
     {
         return (KisImageBuilder_RESULT_NOT_EXIST);
@@ -427,7 +429,7 @@
     if (!uri.isLocalFile())
         return KisImageBuilder_RESULT_NOT_LOCAL;
     // Open file for writing
-    FILE *fp = fopen(uri.path().ascii(), "wb");
+    FILE *fp = fopen(QFile::encodeName(uri.path()), "wb");
     if (!fp)
     {
         return (KisImageBuilder_RESULT_FAILURE);
--- trunk/koffice/filters/krita/tiff/kis_tiff_converter.cc #518324:518325
@@ -24,6 +24,8 @@
 #include <config.h>
 #include LCMS_HEADER
 
+#include <qfile.h>
+
 #include <kapplication.h>
 #include <KoDocumentInfo.h>
 
@@ -154,7 +156,7 @@
     kdDebug(41008) << "Start decoding TIFF File" << endl;
     // Opent the TIFF file
     TIFF *image = 0;
-    if((image = TIFFOpen(uri.path().ascii(), "r")) == NULL){
+    if((image = TIFFOpen(QFile::encodeName(uri.path()), "r")) == NULL){
         kdDebug(41008) << "Could not open the file, either it doesn't exist, either it is not a TIFF : " << uri.path() << endl;
         if (image) TIFFClose(image);
         return (KisImageBuilder_RESULT_BAD_FETCH);
@@ -604,7 +606,7 @@
     
     // Open file for writing
     TIFF *image;
-    if((image = TIFFOpen(uri.path().ascii(), "w")) == NULL){
+    if((image = TIFFOpen(QFile::encodeName(uri.path()), "w")) == NULL){
         kdDebug(41008) << "Could not open the file for writting " << uri.path() << endl;
         TIFFClose(image);
         return (KisImageBuilder_RESULT_FAILURE);
Comment 4 younker 2006-03-14 00:20:21 UTC
How to use this patch?

i can't apply it to krita source codes. 
Comment 5 Cyrille Berger 2006-03-14 08:30:54 UTC
pasting from "--- trunk/koffice/filters/krita/jpeg/kis_jpeg_converter.cc #518324:518325" to the end of my message in a text file (called for instance "krita-chinese.patch"

and patch -p1 <krita-chinese.patch in the koffice source directory should work, I don't think the code between svn and beta2 is that different to prevent the patch to be applied.