[Baypiggies] Handling unwanted Unicode \u2019 characters in XML

Terry Carroll carroll at tjc.com
Wed Jul 2 03:05:18 CEST 2008


On Tue, 1 Jul 2008, Terry Carroll wrote:

> On Tue, 1 Jul 2008, Stephen McInerney wrote:
> 
> > Check that URL again: string.translate() IS deprecated, but
> > string.maketrans() is not. unicode.translate() is not deprecated.
> 
> But can you set up the translate table, though?

Ah, here's how it works:

>>> d = u"doesn\u2019t"    # "doesn't", with a curly-quote
>>> trtab={0x2019:u"'"}    # map codepoint 2019 to the "'" character
>>> d.translate(trtab)
u"doesn't"





More information about the Baypiggies mailing list