Chapter 20.2. Dealing with Unicode in TurboGears

A lot of effort has gone into TurboGears to make sure it plays nicely with respect to Unicode. Rather than make you responsible for handling everything yourself, TurboGears transparently encodes and decodes strings for you—most of the time.

For example, whenever you use turbogears.flash(), you pass a Unicode string to it that is correctly encoded to UTF-8 to set a cookie and then sent to the browser. When TurboGears receives the cookie back from the browser on a later request, it turns the cookie back into a Unicode string so that it can be processed in Python. Then, when it’s returned to the browser for display, it’s re-encoded in UTF-8 in order to display correctly to the user.

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.