utf8 and ftplib

Richard Lewis richardlewis at fastmail.co.uk
Mon Jun 20 09:48:21 EDT 2005


On Mon, 20 Jun 2005 14:27:17 +0200, "Fredrik Lundh"
<fredrik at pythonware.com> said:
>
> well, you're messing it up all by yourself.  getting rid of all the
> codecs and
> unicode2charrefs nonsense will fix this:
> 
Thanks for being so patient and understanding.

OK, I've taken it all out. The only thinking about encoding I had to do
in the actual code I'm working on was to use:
file.write(document.toxml(encoding="utf-8"))

instead of just
file.write(document.toxml())

because otherwise I got errors on copyright symbol characters. (And
similarly, I had to use file.write(unicode_string.encode("utf-8")) in
another part of the actual code in order to prevent the same problem.)

My code now works without generating any errors but Konqueror's KHTML
and Embedded Advanced Text Viewer and IE5 on the Mac still show
capital-A-with-a-tilde in all the files that have been
generated/altered. Whereas my text editor and Mozilla show them
correctly.

The "unicode2charrefs() nonsense" was an attempt to make it output with
character references rather than literal characters for all characters
with codes greater than 128. Is there a way of doing this? (I know
people will argue that character references are only preferred by humans
and text editors, but if I could generate my output HTML documents with
character references rather than literal characters then I wouldn't have
the problem of incorrectly displayed characters on Konqueror and IE 5
for Mac. Which would be nice.)

Cheers,
Richard



More information about the Python-list mailing list