Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106654

RE: COnvert to unicode

From Joaquin Alzola <Joaquin.Alzola@lebara.com>
Newsgroups comp.lang.python
Subject RE: COnvert to unicode
Date 2016-04-07 23:23 +0000
Message-ID <mailman.67.1460098875.2253.python-list@python.org> (permalink)
References <DB5PR07MB1496D15C3C8636336BD17DDEF0900@DB5PR07MB1496.eurprd07.prod.outlook.com> <ne680s$sqr$1@ger.gmane.org> <DB5PR07MB1496B4AFBD6EB44DCE138373F0900@DB5PR07MB1496.eurprd07.prod.outlook.com>

Show all headers | View raw


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@python.org] On Behalf Of Peter Otten
Sent: 07 April 2016 19:14
To: python-list@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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: COnvert to unicode Joaquin Alzola <Joaquin.Alzola@lebara.com> - 2016-04-07 23:23 +0000

csiph-web