Converting foreign characters to HTML characters entities

Michael Ströder michael at
Mon May 28 10:54:52 EDT 2001

Lutz Schroeer wrote:
> My program reads strings out of a database and converts them to an HTML-
> page. The string contains German Umlauts which I would like to convert to
> HTML character entities.

How are the characters encoded in your database? Assuming you are
using Python 2.0+ you should look into Unicode support and codecs.

BTW: You don't have to convert to HTML character entities. It's
sufficient to set the charset in the HTTP header and/or <head>
section to utf-8 and send UTF-8 chars to the web browser.

Ciao, Michael.

More information about the Python-list mailing list