COnvert to unicode

Joaquin Alzola Joaquin.Alzola at lebara.com
Thu Apr 7 19:23:23 EDT 2016


Thanks Peter. Much appreciate will look into codecs and how they work.

-----Original Message-----
From: Python-list [mailto:python-list-bounces+joaquin.alzola=lebara.com at python.org] On Behalf Of Peter Otten
Sent: 07 April 2016 19:14
To: python-list at python.org
Subject: Re: COnvert to unicode

Joaquin Alzola wrote:

> Hi People
>
> I need to covert this string:
>
> hello  there
> this is a test
>
> (also \n important)
>
> To this Unicode:
>
00680065006c006c006f0020002000740068006500720065000a00740068006900730020006900730020006100200074006500730074000a
> Without the \u and space.
>
> https://www.branah.com/unicode-converter
>
> I seem not to be able to do that conversion.
>
> Help to guide me will be appreciated.

>>> import codecs
>>> s = u"hello  there\nthis is a test\n"
>>> codecs.encode(s.encode("utf-16-be"), "hex")
'00680065006c006c006f0020002000740068006500720065000a00740068006900730020006900730020006100200074006500730074000a'


--
https://mail.python.org/mailman/listinfo/python-list
This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.



More information about the Python-list mailing list