Print Page | Close Window

Special Characters File names

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: General Discussion
Forum Description: Discussion board for Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2051
Printed Date: 22 Nov 24 at 7:47PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Special Characters File names
Posted By: Ilana
Subject: Special Characters File names
Date Posted: 22 Nov 11 at 3:30AM
Hi,

When trying to open a pdf file in a directory that has German characters, the returned handle is 0. Which means that the file could not be opened.
The command DAOpenFile when the file is: "c:\\drop\\ùéèçà1232\\pages.pdf". Any solution for that?
I am using "QuickPDFDLL0723.dll".

Thanks,
Ilana.



Replies:
Posted By: Wheeley
Date Posted: 22 Nov 11 at 5:48AM
I can think of 3 ideas.
1. Make sure you send the file name as a UTF8 encoded string to the 7.23 DLL.
2. Try the 7.26 DLL with UTF8 encoding as well
3. Upgrade to version 8 with full unicode support

Wheeley


Posted By: Ilana
Date Posted: 22 Nov 11 at 10:58PM
I am using UTF-8 characters which has their value is bigger then 127. For example one of the characters has the Ansi value  of 199 and 200. Can you please advice? Thanks, Ilana.


Posted By: Ingo
Date Posted: 23 Nov 11 at 8:50AM
Hi Ilana!

Wheeley already told you what to do ...
Try things like this:
QP.LoadFromFile(Pchar( AnsiToUtf8(c:\\drop\\ùéèçà 1232\\pages.pdf) ))
QP.LoadFromFile(UTF8Encode('c:\\drop\\ùéèçà 1232\\pages.pdf')

...and don't forget Wheeley's ideas 2 and 3 ;-)

Cheers and welcome here,
Ingo



Posted By: Ilana
Date Posted: 23 Nov 11 at 9:50PM
Thanks!
For future users, here is the actual code, that works:
In C++:
char *fname = "C:\\Temp\\Digi drop\\ùéèçà123\\pages.pdf";
const int SIZE = 1024; // Bytes
                char* text = new char[SIZE];
                WCHAR w[SIZE]={0};

int erg=MultiByteToWideChar(CP_ACP, 0, fname, -1, w, SIZE); // ANSI to UNICODE
erg=WideCharToMultiByte(CP_UTF8, 0, w, -1, text, SIZE, 0, 0); // UNICODE to UTF-8 
int hndFile = _QuickPDFDAOpenFile (InstanceID, text, NULL);
if (hndFile != 0)
{
int x = 1;
}
In Java 6 - How to get the same UFT-8 path:
public String getAsString (String result)  
        { 
byte[] bt = result.getBytes(); 
ByteArrayOutputStream sw = new ByteArrayOutputStream (bt.length);
                OutputStreamWriter osw;
try {
osw = new OutputStreamWriter (sw, "UTF8");
       BufferedWriter out = new BufferedWriter (osw); 
       out.write(result ); 
       out.close(); 
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
        return sw.toString(); 
    }





Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk