On Fri, Apr 8, 2016 at 1:33 AM, Joaquin Alzola
<joaquin.alz...@lebara.com> wrote:
> hello  there
> this is a test
>
> (also \n important)
>
> To this Unicode:
> 00680065006c006c006f0020002000740068006500720065000a00740068006900730020006900730020006100200074006500730074000a
> Without the \u and space.

What happens if you have a non-BMP codepoint? So far, what you have is
pretty straight-forward.

>>> s = "hello  there\nthis is a test\n"
>>> "".join("%04x" % ord(x) for x in s)
'00680065006c006c006f0020002000740068006500720065000a00740068006900730020006900730020006100200074006500730074000a'

But if you have codepoints that don't fit in four hex digits, this
will mess up your formatting. You'll need to decide how to handle
those.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to