Convert from unicode chars to HTML entities
Roberto Bonvallet
rbonvall at alumnos.inf.utfsm.cl
Thu Feb 8 12:58:33 EST 2007
Steven D'Aprano <steve at removeme.cybersource.com.au> wrote:
> I have a string containing Latin-1 characters:
>
> s = u"© and many more..."
>
> I want to convert it to HTML entities:
>
> result =>
> "© and many more..."
[...[
> Is there a "batteries included" solution that doesn't involve
> reinventing the wheel?
recode is good for this kind of things:
$ recode latin1..html -d mytextfile
It seems that there are recode bindings for Python:
$ apt-cache search recode | grep python
python-bibtex - Python interfaces to BibTeX and the GNU Recode library
HTH, cheers.
--
Roberto Bonvallet
More information about the Python-list
mailing list