UP | HOME

Decode Characters in Python

class CP037Decoder:
│ _CHARSET_ = 'cp037'def __init__(self, message):
│   self.decode_message = unicode(message, self._CHARSET_)
│
│ def show_in_utf8(self):
│   print self.decode_message.encode('utf8')
│
if __name__ == '__main__':
│ msg_file = open(sys.argv[1], 'r')
│ CP037Decoder(msg_file.read()).show_in_utf8()
│ msg_file.close()