[Baypiggies] Html encoding question

Shannon -jj Behrens jjinux at gmail.com
Thu Jun 7 10:01:47 CEST 2007


On 6/7/07, Ken Seehart <ken at seehart.com> wrote:
> Is there a handy function somewhere that converts a string so that the
> result will display as plain text in an html document?  Somewhat
> analogous to urlencode but not exactly.
>
> So for example
>
>  >>> html_str_encode('where x < z*5, and x > z+2')
> 'where x &lt; z*5, and x &gt; z+2'
>
> I'm pretty sure I've seen this before, but I just can't seem to find it
> today.  Maybe I just need more coffee.
>
> Thanks,
> - Ken

>>> import cgi
>>> cgi.escape('where x < z*5, and x > z+2')
'where x &lt; z*5, and x &gt; z+2'

It's more simple than complete, but it works for the standard stuff.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/


More information about the Baypiggies mailing list