AnsweredAssumed Answered

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 6: ordinal not in range(128)

Question asked by timothy_hales-esristaff Employee on Dec 2, 2014
Latest reply on Dec 2, 2014 by timothy_hales-esristaff

I am trying to convert unicode to string, but I am getting UnicodeDecodeError. The original issue is related to working with a json return and creating a string, but here is a simplified example:

 

raw = unicode("Soporté")
print string

 

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 6: ordinal not in range(128)

 

I have tried the suggestion from here: Rename layer with unsupported signs in a mxd via python?

raw = unicode("Soporté")
string = raw.decode('utf-8')
print string

 

And here: Write Russian field names to txt

raw = unicode("Soporté")
string = raw.encode('utf-8')
print string

 

But I get the same error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 6: ordinal not in range(128)

Outcomes