0x1_c0de_bad
0x1_c0de_bad

Reputation: 33

Get unicode string out of binary data in python

I have some UCF-2 data in a normal string received from a server. How can I get a unicode() string out of this?

EG: >>> something('\0a\0b\0c') = u'abc'

Upvotes: 3

Views: 1355

Answers (1)

dan04
dan04

Reputation: 91209

>>> '\0a\0b\0c'.decode('UTF-16BE')
u'abc'

Upvotes: 4

Related Questions