Htmlizing text

Fredrik Lundh fredrik at pythonware.com
Tue Nov 30 14:46:49 CET 1999


Gerrit Holl <gerrit.holl at pobox.com> wrote:
> This is better:
>
> def escapeall(s):
> import htmlentitydefs
> for k, v in htmlentitydefs.items():
> s = string.replace(s, v, '&' + k)
> return s

I assume this is untested code?

> By the way, why doesn't the cgi module does this?

if you use ISO Latin 1 for your pages (which happens to
be default in HTTP/1.1, HTML 3.0, and real life), you
don't really have to quote all possible entities just be-
cause you can...

also see:
http://www.lysator.liu.se/åttabitars/ (*)

</F>

    "mangling 8-bit data down to 7 bits is broken,
    and has no excuses." -- linus torvalds

*) ie 5.0 users should use this link instead:
http://www.lysator.liu.se/%e5ttabitars/





More information about the Python-list mailing list