Is there a way to get utf-8 out of a Unicode string?

thebjorn BjornSteinarFjeldPettersen at gmail.com
Mon Oct 30 04:15:03 EST 2006


Gerrit Holl wrote:
> Hei,
>
> On 2006-10-30 08:25:41 +0100, thebjorn wrote:
> >   def unfk(s):
> >       return eval(repr(s)[1:]).decode('utf-8')
> >
...
> > Is there a less hack'ish way to do this?
>
> Slightly lack hackish:
>
> return ''.join(chr(ord(c)) for c in s)

Much less hackish :-)

-- bjorn




More information about the Python-list mailing list