Python How To Encode 0x90(\x90) As MacOS Roman Encoding To \xc3\xaa
In python, if giving 0x90(or \x90), how to encode it into a string as macOS Roman Encoding to \xc3\xaa, aka ê? I tried bytes('\x90').encode('mac-roman'), it just throw errors. chr
Solution 1:
It depends on what you final goal is, but as such it is encoded, so you first need to decode it, i mean, e.g.
chr(0x90).decode('mac-roman')
You were almost there.
Solution 2:
Actually, after searching two web pages: http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT it shows:
0x90 0x00EA # LATIN SMALL LETTER E WITH CIRCUMFLEX
and http://www.fileformat.info/info/unicode/char/ea/index.htm,:
UTF-8 (hex) 0xC3 0xAA (c3aa)
UTF-8 (binary) 11000011:10101010
UTF-16 (hex) 0x00EA (00ea)
and trying decoding/encoding, I found it's:
'\x90'.decode('mac-roman').encode('utf-8')
Post a Comment for "Python How To Encode 0x90(\x90) As MacOS Roman Encoding To \xc3\xaa"