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

Wrong encoding of whole document if meta encoding is specified after UTF-8 title #768

Closed
xmeloun opened this issue Jan 20, 2014 · 1 comment
Labels

Comments

@xmeloun
Copy link

xmeloun commented Jan 20, 2014

If the encoding is specified after an UTF-8 output is sent (title), the encoding of the whole document is wrong.

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
<html>
    <head>
                <title>žšššýčř</title>
        <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
    </head>

If I put the meta before the title, everything's OK.

@bsweeney
Copy link
Member

This is an issue with DOMDocument, which dompdf relies on. I thought this issue was already addressed, but that does not appear to be the case. There are two work arounds that require minimal effort:

  1. Placing the HTML meta element before the title element (as you indicated).
  2. Enable the HTML5 parser (v 0.6.0 and greater), by modifying the DOMPDF_ENABLE_HTML5PARSER setting in your configuration file.

Personally, I recommend enabling the HTML5 parser. Beyond addressing this issue, it can help prevent DOMDocument processing errors by correcting syntactical problems in the HTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants