Convert UTF-8 octets to unicode code points?

I'm assuming pre-3.x... Put them in a str, and either call unicode with the string and 'utf-8': >>> unicode('\xc5\x81', 'utf-8') u'\u0141' Or call . Decode('utf-8') on the str: >>> '\xc5\x81'. Decode('utf-8') u'\u0141' If by "octet" you really mean a string in the form '0xc5' (rather than '\xc5') you can convert them like this: >>> ''.

Join(chr(int(x,0)) for x in '0xc5', '0x81') '\xc5\x81.

1, well explained! – YOU Dec 8 '09 at 5:11 1 +1: Also, int(x,0) has the advantage of permitting mixed base octect string, for example, '0xc5', '0x81', '0305', '0201' are the hex and octal representations of the same. Int(x,16) would misinterpret the octal strings in this input – mhawke Dec 8 '09 at 5:42.

L = '0xc5','0x81' s = ''. Join(chr(int(c, 16)) for c in l). Decode('utf8') s >>> u'\u0141.

In lovely 3. X, where all strs are Unicode, and bytes are what strs used to be: >>> s = str(bytes(0xc5, 0x81), 'utf-8') >>> s 'ŝ' >>> ord(s) 321 >>> hex(ord(s)) '0x141' Which is what you asked for.

. Join((chr(int(x,16)) for x in '0xc5','0x81')). Decode("utf8") u'\u0141.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions