0

I have found out a problem with python 3.6.7 when I tried to stringfy a hexadecimal value. The original hexadecimal number in the string is wrongly converted into an acsii letter Ë. Is there any way for solving this?

>>>  '\xcb\x85\x04\x08'
'Ë\x85\x04\x08'
  • 3
    What was your input and what instruction(s) did you run? – Dragonthoughts Jun 13 '19 at 15:02
  • We're missing some context as to why "Ë" would be considered "wrongly converted". Perhaps you're coming from Python 2? The topic of bytes vs strings is one of the big changes between the two major versions. – TrebledJ Jun 13 '19 at 15:15
  • Possible duplicate of [Write different hex-values in Python2 and Python3](https://stackoverflow.com/questions/32017389/write-different-hex-values-in-python2-and-python3) – TrebledJ Jun 13 '19 at 15:15

1 Answers1

0

You are using characters outside of the ascii code. If you are trying to use unicode, use \u____.

print("\xCB\x85\x04\x08")
print("\uCB89\u0408")

Output:

Ë

쮉Ј

You can find an ascii table at asciitable.com. Characters outside of the range 00-7F are subject to variance across regions due to the use by many countries to store extra characters that are useful in their common language, such as russian characters in russia.