Changes between Version 43 and Version 44 of GenshiFaq
- Timestamp:
- Mar 1, 2008, 11:51:35 AM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GenshiFaq
v43 v44 159 159 Genshi refuses to work with bytestrings that do not use the system default encoding, which on most systems is ASCII. This behavior is by design. If you want to render strings that contain characters outside of the ASCII range (or don't use the system default encoding), you will have to pass `unicode` objects to Genshi. 160 160 161 This doesn't mean that Genshi has bad support for non-ASCII strings. Quite the contrary -- Genshi works beautifully with unicode. It just requires that you do the decoding of your bytestrings before passing the data to the templates. If this data comes from a database, it's likely that your database connector provides an option to automatically decode any data to unicode. SQLAlchemy, for example, provides a `convert_unicode` flag you can specify when [http://www.sqlalchemy.org/docs/dbengine.html#dbengine_options creating an engine]. Set that flag to `True`, and you get rid of a whole class of potentially nasty problems.161 This doesn't mean that Genshi has bad support for non-ASCII strings. Quite the contrary -- Genshi works beautifully with unicode. It just requires that you do the decoding of your bytestrings before passing the data to the templates. If this data comes from a database, it's likely that your database connector provides an option to automatically decode any data to unicode. [http://www.sqlalchemy.org/ SQLAlchemy], for example, provides a `convert_unicode` flag you can specify when [http://www.sqlalchemy.org/docs/dbengine.html#dbengine_options creating an engine]. Set that flag to `True`, and you get rid of a whole class of potentially nasty problems. 162 162 163 163 For more information on unicode and using unicode in Python applications, see: