I got a bytes data including Japanese Yen symbol (¥). This seems to be expressed as \xc2\xa5
.
However, I can't decode the yen symbol. For example,
yen = b"\xc2\xa5"
type(yen) # return bytes
yen.decode("utf-8") # return UnicodeEncodeError: 'ascii' codec can't encode character '\xa5' error
import chardet
chardet.detect(yen) # return {'confidence': 0.73, 'encoding': 'windows-1252'}
yen.decode("windows-1252") # return another UnicodeEncodeError: 'ascii' codec can't encode characters error
The bytes data I have can be decoded as utf-8
in other aspects. Only Japanese Yen symbol cannot be decoded, no matter what encoding you use.
So how can I decode it?