Bug 70947 - KPDF can't open files whose names have non-ASCII letters
Summary: KPDF can't open files whose names have non-ASCII letters
Status: RESOLVED FIXED
Alias: None
Product: kpdf
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Christophe Devriese
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-21 00:37 UTC by Thiago Macieira
Modified: 2004-03-06 19:11 UTC (History)
1 user (show)

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


Attachments
Henrique's patch solving the problem (387 bytes, patch)
2004-03-04 01:40 UTC, Thiago Macieira
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thiago Macieira 2003-12-21 00:37:52 UTC
Version:           v0.3 (using KDE 3.1.94 (CVS >= 20031206), compiled sources)
Compiler:          gcc version 3.3.2
OS:          Linux (i686) release 2.6.0

When in an UTF-8 locale, KPDF can't open any files whose names contain non-ASCII letters, both names in the command-line and in the Open File dialog. The error I get in the screen is the same.

When using a standard Latin1 locale, this doesn't happen.

The following errors come from a Latin1 Konsole so that all characters are visible:

$ LANG=pt_BR.UTF-8 kpdf /tmp/Namárië.pdf
Error: Couldn't open file '/tmp/Namárië.pdf'

$ LANG=pt_BR kpdf /tmp/Namárië.pdf
[file is opened correctly]

$ LANG=el_GR kpdf /tmp/Namárië.pdf
Error: Couldn't open file '/tmp/Nam??ri?«.pdf'

$ touch /tmp/¤
$ LANG=fr_FR@euro kpdf /tmp/¤
Error: Couldn't open file '/tmp/?'

Somehow KPDF isn't using the proper functions to handle filenames. It's very likely converting the names into Latin1 when trying to open it, instead of using QFile::encoding.
Comment 1 Thiago Macieira 2003-12-21 00:41:04 UTC
The bugzilla page and the e-mail sent by Bugzilla are correctly encoded in UTF-8. In all kpdf command-lines you should be seeing 9 letters between /tmp/ and .pdf. If you don't, change the settings in your browser/mail reader.
Comment 2 Dominique Devriese 2004-01-02 02:07:09 UTC
I can't reproduce this bug report.  I have moved a pdf to the name /tmp/tést.pdf and it opens fine, both from the command line as the open file dialog.

unconfirming.

cheers
domi
Comment 3 Thiago Macieira 2004-01-04 04:13:53 UTC
Nope, still happening for me.

Note: you need to have a file whose name is not ASCII and you have to be in a non-Latin1 or Latin9 locale. UTF-8 serves best.

I noted up above that Latin1 worked.
Comment 4 Thiago Macieira 2004-01-15 01:43:11 UTC
*** Bug 72667 has been marked as a duplicate of this bug. ***
Comment 5 Thiago Macieira 2004-01-15 01:45:18 UTC
Oops, sorry for the mishap. I mistook kpf for kpdf.

I might add that this is still happening for me as of HEAD 20031222.
Comment 6 Thiago Macieira 2004-03-04 01:38:32 UTC
Forwarding to the bug report; the file will be attached to it.

----------    ----------
Subject: Solving bug #70947
Date: Qua 03 Mar 2004 21:07
From: Henrique Pinto <henrique.pinto@kdemail.net>
To: oelewapperke@wina.be
Cc: thiago.macieira@kdemail.net

Hi!

I recently had the same problem Thiago reported. After a quick check of
the code, I discovered where the bug was lying and created the tiny
patch attached to this message, that solves the problem for me.

Can I commit this?

Thank you!

--
	Henrique Pinto
	henrique.pinto@kdemail.net

-------------------------------------------------------
--- kpdf_part.cpp	2004-01-10 16:49:40.000000000 -0200
+++ /home/henrique/kpdf_part.cpp	2004-03-03 20:47:52.000000000 -0300
@@ -351,7 +351,7 @@
   if (file.open(IO_ReadOnly) == false)
     return false;
 
-  GString* filename = new GString(m_file.ascii());
+  GString* filename = new GString( QFile::encodeName( m_file ) );
   m_doc = new PDFDoc(filename, 0, 0);
 
   if (!m_doc->isOk())
Comment 7 Thiago Macieira 2004-03-04 01:40:40 UTC
Created attachment 5010 [details]
Henrique's patch solving the problem

No, that didn't work. Here goes through Bugzilla.
Comment 8 Henrique Pinto 2004-03-05 00:59:59 UTC
> No, that didn't work.

Strange... Very strange... It works like a charm for me...


Anyway, I still think the patch should be applied, as the filename shouldn't be converted to ASCII. I'll check other potential sources of errors related to this.
Comment 9 Thiago Macieira 2004-03-05 03:52:56 UTC
>> No, that didn't work. 
 
> Strange... Very strange... It works like a charm for me... 

I meant that sending an e-mail to the bug report did not attach the file to it. It pasted the contents instead.
Comment 10 Henrique Pinto 2004-03-06 19:11:09 UTC
CVS commit by pinto: 


Support non-ASCII filenames.

CCMAIL: 70947-done@bugs.kde.org


  M +1 -1      kpdf_part.cpp   1.47


--- kdegraphics/kpdf/kpdf/kpdf_part.cpp  #1.46:1.47
@@ -352,5 +352,5 @@ Part::openFile()
     return false;
 
-  GString* filename = new GString(m_file.ascii());
+  GString* filename = new GString( QFile::encodeName( m_file ) );
   m_doc = new PDFDoc(filename, 0, 0);