I have an UTF-8 character encoded with `_' in between, e.g., '_ea_b4_80'. I'm trying to convert it into UTF-8 character using replace method, but I can't get the correct encoding.
This is a code example:
import sys
reload(sys)
sys.setdefaultencoding('utf8')
r = '_ea_b4_80'
r2 = '\xea\xb4\x80'
r = r.replace('_', '\\x')
print r
print r.encode("utf-8")
print r2
In this example, r is not the same as r2; this is an output.
\xea\xb4\x80
\xea\xb4\x80
관 <-- correctly shown
What might be wrong?