Louis.CLast
Louis.CLast

Reputation: 454

How to convert unicode string to decimal number in python?

Example i have this text string:

string = 'Vui lòng giúp đỡ tôi'

How to convert it to integer to use with unichr() ?

Example result:

\u...\u...

Upvotes: 0

Views: 1422

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798696

You don't need to, if you decode it.

>>> 'Vui lòng giúp đỡ tôi'
'Vui l\xc3\xb2ng gi\xc3\xbap \xc4\x91\xe1\xbb\xa1 t\xc3\xb4i'
>>> 'Vui lòng giúp đỡ tôi'.decode('utf-8')
u'Vui l\xf2ng gi\xfap \u0111\u1ee1 t\xf4i'
>>> print 'Vui lòng giúp đỡ tôi'.decode('utf-8')
Vui lòng giúp đỡ tôi

Upvotes: 1

Related Questions