I'm trying to transform this unicode value:
string_value = u'd\xe9cid\xe9'
to
string_value = u'décidé'
I feel like I've tried everything:
decoded_str = string_value.decode('utf-8')
or
string_value = str(string_value)
decoded_str = string_value.encode('latin1').decode('utf-8')
or
string_value = string_value.decode('latin-1')
for this one the result is:
d\xc3\xa9cid\xc3\xa9
I have the same result if I do:
string_value = string_value.encode('utf-8')
I've read from: How do I convert 'blah \xe9 blah' to 'blah é blah'
also from: Why does Python print unicode characters when the default encoding is ASCII?
and: How do I convert a unicode to a string at the Python level?
EDIT:
My problem is I need to use the data, I mean if I have :
string_value = u'mai 2017 \u2013 Aujourd\u2019hui'
which is :
mai 2017 – Aujourd’hui
I want to do:
string_list = string_value.split('-')
But the result is:
[u'mai 2017 \u2013 Aujourd\u2019hui']
And I would:
['mai 2017', 'Aujourd’hui']
NEW EDIT:
I understand that I'm going to the wrong direction, thanks to your answer. \xe9 is the right representation of 'é' and it's not a problem. My real issue is why does json.loads() transform 'mai 2017 – Aujourd’hui' to 'mai 2017 \u2013 Aujourd\u2019hui' ?