Forum Bugs

Non-ASCII chars won't print in header?

dsewell
I'm trying to get some non-ASCII characters into generated headers, and it's not working. Here's my input document:
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Test</title>
    <style type="text/css">
      @page {
        @top-left { content: 'This is a "left" header' }
        @top-right { content: 'This is a &​#8220;right&​#8221; header' }
      }
    </style>
  </head>
  <body>
    <h1>Test</h1>
    <p>This is "straight quotes" and “curly quotes”.</p>
  </body>
</html>

The left header, with the ASCII quotation marks, is fine, but the right header is null; I assume the reason is the use of the Unicode “curly quotation marks” (U-8220 and U-8221) in the content attribute. Even HTML 4.0 Latin-1 entities break the header, e.g. &​#169; (the © symbol).

Is this a limitation in CSS or in Prince? There are times when you really need non-ASCII characters in a header or footer, so if at all possible, can they be enabled?

David Sewell, Editorial and Technical Manager
Electronic Imprint, The University of Virginia Press
Web: http://rotunda.upress.virginia.edu/

mikeday
You can add non-ASCII characters to CSS generated content using CSS character escapes rather than XML character entities, like this:

@page {
        @top-left { content: 'This is a "left" header' }
        @top-right { content: 'This is a \201C right\201D  header' }
} 

Note that these escapes begin with a \ character, have the UNICODE character as a hexadecimal number, and are followed by a trailing space character, which is why there are two space characters after the close quote, as the first space is part of the character escape.

In future we will add UNICODE character support directly to CSS style sheets, so that XML character escapes will work as well (assuming that the CSS is inside an XML document rather than in an external file).
dsewell
mikeday wrote:
You can add non-ASCII characters to CSS generated content using CSS character escapes rather than XML character entities, like this:

@page {
        @top-left { content: 'This is a "left" header' }
        @top-right { content: 'This is a \201C right\201D  header' }
} 

Thanks, that does the trick,

DS

David Sewell, Editorial and Technical Manager
Electronic Imprint, The University of Virginia Press
Web: http://rotunda.upress.virginia.edu/

mikeday
This issue has been fixed in Prince 5.1 rev 3, so that you can use XML entities or UNICODE characters directly in CSS strings within the <style> element.