Generate a UTF-8 encoded Actinic site

I don’t like the way of Actinic tackle the problem. For example, if the web server set default charset as UTF-8, it will cause page rendering issue for Actinic. Especially for the pound sign. All the support knowledge from Actinic is redirecting people set the server using default chareset as ISO-8859-1. Then, my question is – why should I use ISO-8859-1 while UTF-8 has far better applicability, especially for multi-national sites?

Nevertheless, can Actinic generate an UTF-8 encoded site? The answer is yes and no.

Yes is because I have already achieved it; No is because Actinic can not make it happen for you (at least I won’t know how to control it), so you must do something outside Actinic. Here below is my detailed steps.

  • First, rewrite all requests to actinic generated files to index.php.
  • Second, create a bootscript, name it as index.php. This idea is inspired by Zend Framework. Make sure:
    1. The bootscript should be in utf-8 encode.
    2. The bootscript should be able to include actinic generate files according to request uri.
  • Third, in actinic templates, change meta tag charset to utf-8.
  • Last, at web server, adddefaultcharset utf-8.

The most tricky part is actinic upload its files in iso-8859-1 encoding, but bootscript is utf-8 encoded. A normal include or require by php will not render pound sign correctly. I use output buffer to hack the problem.

<?php
...
ob_start();
include($actinic);
$utf8out = utf8_encode(ob_get_contents());
ob_end_clean();
echo $utf8out;
?>

Leave a comment

Your email address will not be published. Required fields are marked *