converting to and from octal escaped UTF--8

Michael Goerz answer654 at 8439.e4ward.com
Sun Dec 2 23:56:36 EST 2007


MonkeeSage wrote:
 > Looks like escape() can be a bit simpler...
> 
> def escape(s):
>   result = []
>   for char in s:
>     result.append("\%o" % ord(char))
>   return ''.join(result)
> 
> Regards,
> Jordan
Very neat! Thanks a lot...
Michael



More information about the Python-list mailing list