How to convert "\x81" to "ü" with codepage 1252 (windows 1252)

204 Views Asked by At

I am stuck with a simple task. I want to convert

\x81

into

ü

with the use of codepage 1252 (windows 1252).

My attempt:

data = "\x81"
print(data.encode('cp1252'))

results with an error:

      File "test.py", line 2, in <module>
    print(data.encode('cp1252'))
  File "/usr/lib/python3.7/encodings/cp1252.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_table)
    UnicodeEncodeError: 'charmap' codec can't encode character '\x81' in position 0: character maps to <undefined>

Can someone help?

0

There are 0 best solutions below