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_set_object_setting can not deal with Chinese characters #2885

Closed
neohope opened this Issue Apr 13, 2016 · 6 comments

Comments

Projects
None yet
2 participants
@neohope

neohope commented Apr 13, 2016

It seems that "wkhtmltopdf_set_object_setting" function can not deal with Chinese characters.

I hava tried ansi, unicode and utf-8.

Did I miss something?

//ansi or gbk    
wkhtmltopdf_set_object_setting(os, "header.left", "测试");

//unicode
int outLength = MultiByteToWideChar(CP_ACP, 0, "测试", -1, NULL, 0);
WCHAR *wbuff = (WCHAR *)malloc(outLength+1);
memset(wbuff, 0, outLength+1);
outLength = MultiByteToWideChar(CP_ACP, 0, "测试", -1, wbuff, outLength);
wkhtmltopdf_set_object_setting(os, "header.left", wbuff);

//utf-8
outLength = WideCharToMultiByte(CP_UTF8, 0, wbuff, -1, NULL, 0, NULL, NULL);
char* ubuff = (char*)malloc(outLength + 1);
memset(ubuff, 0, outLength + 1);
outLength = WideCharToMultiByte(CP_UTF8, 0, wbuff, -1, ubuff, outLength, NULL, NULL);
wkhtmltopdf_set_object_setting(os, "header.left", ubuff);

@neohope neohope closed this Apr 13, 2016

@neohope neohope reopened this Apr 13, 2016

@neohope

This comment has been minimized.

neohope commented Apr 13, 2016

The render results:

utf-8
gbk
unicode

@ashkulz

This comment has been minimized.

Member

ashkulz commented Apr 13, 2016

This should be fixed via something similar to changes in PR 2858, but applied to wkhtmltopdf_set_object_setting instead.

@ashkulz ashkulz added the HasPatch label Apr 13, 2016

@neohope

This comment has been minimized.

neohope commented Apr 13, 2016

Thank you so muchu @ashkulz !

@neohope neohope closed this Apr 13, 2016

@ashkulz

This comment has been minimized.

Member

ashkulz commented Apr 13, 2016

@neohope: so did you compile and verify it? If so, can you submit a PR?

@neohope

This comment has been minimized.

neohope commented Apr 14, 2016

It took me one night to download the souce code from github. Bad GWF.

It worked.

patched

ashkulz added a commit that referenced this issue Apr 14, 2016

enforce UTF-8 encoding for input strings in the API
This was assumed but not enforced, which could cause problems on
Windows where the default encoding is almost never UTF-8.

fixes #2885

@ashkulz ashkulz added Fixed and removed HasPatch labels Apr 14, 2016

@ashkulz ashkulz added this to the 0.12.4 milestone Apr 14, 2016

@ashkulz

This comment has been minimized.

Member

ashkulz commented Nov 23, 2016

0.12.4 has been released, which should contain the fix for this issue. Please report back if it is not solved with the above version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment