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

no support h5 element with utf-8? #490

Closed
byshome opened this issue Jul 27, 2017 · 1 comment
Closed

no support h5 element with utf-8? #490

byshome opened this issue Jul 27, 2017 · 1 comment

Comments

@byshome
Copy link

byshome commented Jul 27, 2017

code:

weasyprint.HTML(string="<h5>我是</h5>", encoding="utf-8").write_pdf("/tmp/a.pdf")

then, pdf file body is
带兒

@liZe
Copy link
Member

liZe commented Jul 27, 2017

Thanks for your report.

Short answer: there's no problem in WeasyPrint.

Encoding questions are hard to understand, I'll try to be as clear as possible and I won't explain what an encoding is as you can read really interesting articles elsewhere about that. Instead, I'll let you try various solutions and let you ask if you're interested in why it solved your problem (if you're not, we will both save a lot of time 😄).

First of all: Remove the encoding parameter, it's useless for you.

Try one/many of:

  • If you're in an interactive terminal, or if you don't mind getting a quick and dirty solution, replace "<h5>我是</h5>" by u"<h5>\u6211\u662f</h5>". I can't find a configuration where this solution doesn't work.
  • If you use Python 2, use u"<h5>我是</h5>" instead of "<h5>我是</h5>".
  • Check that your file is stored on your disk using the UTF-8 encoding. Your text editor can do that.
  • Check that there's no encoding set in a comment at the top of your file (Python 3.x) or that the encoding set is UTF-8.

I'm closing this issue as there's nothing to do in WeasyPrint, but don't hesitate to comment and ask if needed, I'll do my best to help you.

@liZe liZe closed this as completed Jul 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants