Unicode -> String problem

Martin v. Loewis martin at v.loewis.de
Mon Sep 9 01:39:28 EDT 2002


pinard at iro.umontreal.ca (François Pinard) writes:

> For now, I would presume that `codecs.ascii_encode(UNICODE_STRING)' does the
> same as `UNICODE_STRING.encode("ascii")' and consequently, we do not need to
> know about `ascii_encode'.  Is that right?

In the context of the OP's question, you'd use
UNICODE_STRING.encode("ascii", "replace"), or, perhaps,
codecs.getencoder("ascii")(UNICODE_STRING, "replace").

Regards,
Martin



More information about the Python-list mailing list