In my program I get shift-jis character codes as Python integers which I need to convert to their corresponding utf8 character codes (which should also be in integers). How can I do that? For ASCII you have the helpful functions ord()/chr() which allows you to convert an integer into an ASCII string which you can easily convert to unicode later. I can't find anything like that for other encodings.
Using Python 2.
EDIT: the final code. Thanks everyone:
def shift_jis2unicode(charcode): # charcode is an integer
if charcode <= 0xFF:
string = chr(charcode)
else:
string = chr(charcode >> 8) + chr(charcode & 0xFF)
return ord(string.decode('shift-jis'))
print shift_jis2unicode(8140)