How do I convert a string into big5 encoded characters in Python?

500 Views Asked by At

I have a list of strings that represent big-5 encoded Chinese characters, and I'm trying to print them out as the character and not the alphanumeric string. I've tried encode() and decode() with no success.

For example, one of the strings is 'a7da', and I want it to print 我

string = 'a7da'
string.decode('big5)

This just produces the error 'str' object has no attribute 'decode'.

This does work:

string = b'\xa7\xda'
string.decode('big5')

This gives me back '我'

But how can I get 'a7da' into b'\xa7\xda' format?

0

There are 0 best solutions below