Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wkhtmltopdf 0.12.1 ignores non-ascii characters in command-line arguments #1825

Closed
harmant opened this Issue Jul 2, 2014 · 17 comments

Comments

Projects
None yet
3 participants
@harmant
Copy link

harmant commented Jul 2, 2014

Linux (Debian 7 x32, Ubuntu 14.04 x64):

wkhtmltopdf https://www.google.com/ Cyrillic_Тест.pdf
As result, Cyrillic_.pdf file created (not Cyrillic_Тест.pdf)

wkhtmltopdf 0.12.0, wkhtmltopdf 0.12.1-c22928d worked correctly with this example

@ashkulz

This comment has been minimized.

Copy link
Member

ashkulz commented Jul 3, 2014

Are you sure c22928d worked for you? Because the only relevant commit is bd80412 (which fixed #1546). Can you try reverting that commit and see if it works for you?

@ashkulz ashkulz added the NeedInfo label Jul 3, 2014

@harmant

This comment has been minimized.

Copy link
Author

harmant commented Jul 3, 2014

Yes, I'm sure, c22928d working fine.

@ashkulz

This comment has been minimized.

Copy link
Member

ashkulz commented Jul 3, 2014

Can you try git bisect and see if you can identify the offending commit? You can ignore the changes in Qt submodule (leave it as-is).

@harmant

This comment has been minimized.

Copy link
Author

harmant commented Jul 3, 2014

Sorry, it's too difficult for me :) can you provide compiled static binary for testing?

@ashkulz

This comment has been minimized.

Copy link
Member

ashkulz commented Jul 3, 2014

@harmant: then you'll have to wait till I get access to a linux machine (which may be a week or so) to verify the issue.

@harmant

This comment has been minimized.

Copy link
Author

harmant commented Jul 3, 2014

You are right.

If using fromUtf8 instead fromLocal8Bit in
src/pdf/pdfcommandlineparser.cc
all is OK

@ashkulz

This comment has been minimized.

Copy link
Member

ashkulz commented Jul 4, 2014

@harmant: then I'm really confused how c22928d worked for you, as the commit which broke this for you (bd80412) was before that. Can you paste the output of the locale command over here?

@harmant

This comment has been minimized.

Copy link
Author

harmant commented Jul 4, 2014

LANG=ru_UA.UTF-8
LANGUAGE=ru_UA:ru
LC_CTYPE="ru_UA.UTF-8"
LC_NUMERIC="ru_UA.UTF-8"
LC_TIME="ru_UA.UTF-8"
LC_COLLATE="ru_UA.UTF-8"
LC_MONETARY="ru_UA.UTF-8"
LC_MESSAGES="ru_UA.UTF-8"
LC_PAPER="ru_UA.UTF-8"
LC_NAME="ru_UA.UTF-8"
LC_ADDRESS="ru_UA.UTF-8"
LC_TELEPHONE="ru_UA.UTF-8"
LC_MEASUREMENT="ru_UA.UTF-8"
LC_IDENTIFICATION="ru_UA.UTF-8"
LC_ALL=

@ashkulz

This comment has been minimized.

Copy link
Member

ashkulz commented Jul 4, 2014

Strange, fromLocal8Bit should be the same as fromUtf8 for your locale settings.

@harmant

This comment has been minimized.

Copy link
Author

harmant commented Jul 4, 2014

Ok, will wait for confirmation from someone else.

@harmant

This comment has been minimized.

Copy link
Author

harmant commented Sep 1, 2014

Hello, has anyone else encountered a similar problem?

@ashkulz

This comment has been minimized.

Copy link
Member

ashkulz commented Oct 29, 2014

It looks like this is due to QCoreApplication not being created before the command-line parsing, which makes the system use the ASCII locale (as per this thread). The ideal scenario would be to use QCoreApplication::arguments() but that isn't possible because we need to figure out whether to use graphics or not (--use-xserver). Can you try out this patch?

diff --git a/src/pdf/wkhtmltopdf.cc b/src/pdf/wkhtmltopdf.cc
index 8250262..6823e93 100644
--- a/src/pdf/wkhtmltopdf.cc
+++ b/src/pdf/wkhtmltopdf.cc
@@ -33,6 +33,9 @@
 #include <wkhtmltox/pdfconverter.hh>
 #include <wkhtmltox/pdfsettings.hh>
 #include <wkhtmltox/utilities.hh>
+#if defined(Q_OS_UNIX) || defined(Q_OS_MAC)
+#include <locale.h>
+#endif

 using namespace wkhtmltopdf::settings;
 using namespace wkhtmltopdf;
@@ -113,6 +116,9 @@ void parseString(char * buff, int &nargc, char **nargv) {
 }

 int main(int argc, char * argv[]) {
+#if defined(Q_OS_UNIX) || defined(Q_OS_MAC)
+   setlocale(LC_ALL, "");
+#endif
    //This will store all our settings
    PdfGlobal globalSettings;
    QList<PdfObject> objectSettings;

@ashkulz ashkulz changed the title wkhtmltopdf 0.12.1 ignores non-ascii characters in output pdf filename wkhtmltopdf 0.12.1 ignores non-ascii characters in command-line arguments Oct 29, 2014

@ashkulz ashkulz added Verified and removed NeedInfo labels Oct 29, 2014

@ashkulz ashkulz added this to the 0.12.2 milestone Oct 29, 2014

@inacho

This comment has been minimized.

Copy link

inacho commented Oct 31, 2014

I compiled the latest version with your patch and now works fine 😃

@ashkulz

This comment has been minimized.

Copy link
Member

ashkulz commented Oct 31, 2014

@inacho: does it work fine on Mac without the patch?

@inacho

This comment has been minimized.

Copy link

inacho commented Oct 31, 2014

On Mac I'm running the precompiled binary: wkhtmltopdf 0.12.1 (with patched qt) and it works fine.

On Ubuntu 14.04 I compiled the latest code from the repository with your patch and it solves the issue referenced in #2002

@ashkulz ashkulz closed this in 6f2cafe Oct 31, 2014

@ashkulz ashkulz added Fixed and removed Verified labels Oct 31, 2014

@ashkulz

This comment has been minimized.

Copy link
Member

ashkulz commented Nov 7, 2014

A snapshot build (0.12.2-dev-85cdf36) is available which includes the fix for this issue.

@ashkulz

This comment has been minimized.

Copy link
Member

ashkulz commented Jan 10, 2015

0.12.2 has been released, which includes changes related to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.