Netuality

Taming the big bad websites

Archive for April, 2006

Unicode in Python micro-recipe : from MySQL to webpage via Cheetah

leave a comment

Very easy:

  • start by adding the default-character-set=utf8 in your MySQL configuration file and restart the database server
  • apply this recipe from Activestate Python Cookbook (“guaranteed conversion to unicode or byte string”)
  • inside the Cheetah template, use the ReplaceNone filter:


#filter ReplaceNone
${myUnicodeString}
#end filter

in order to prevent escaping non-ASCII characters.

Now. That’s better.

Written by Adrian

April 14th, 2006 at 11:42 pm

Posted in Tools

Tagged with , , , ,