Serving up UTF-8 in PyBlosxom

It's 2005, people. No room for blogs and other sites without the most basic underpinnings of i18n. Turns out serving up UTF-8 from PyBlosxom is not the complete slam dunk I expected. To be fair, getting it to send UTF-8 was easy, given instructions in the config file. You want to add to your config a line such as:

py['blog_encoding'] = "utf-8"

This does cause PyBlosxom to render UTF-8 pages. But you also have to be sure the browser knows the pages are in UTF-8, or most browsers I've found will default to ISO-8859-1 and thus garble non-ASCII characters. I tried using HTML meta, by adding the following to the head template for my flavor (head.copia):

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

But this was not enough. Browsers rightly prefer to believe the HTTP content type header, so the trick lies in the content_type template for your flavor. Most HTML templates you find out there contain only text/html. You want to expand this to

text/html; charset=UTF-8

Your browser probably gives you a "page info" display of some sort with which you can check that your content type header is right. In Firefox 1.0.2 it's Tools -> Page Info or Ctrl+I. See the following example dialog:

Firefox page info dialog for Copia

[Uche Ogbuji]

via Copia