Reputation: 23980
I've been reading some articles about unicode (this and this), but still don't understand how to do something as simple as this (in python 2.7):
From
x = 'm\\u00e1s'
I want to obtain the unicode string u'm\u00e1s'
("más").
What is the right way to do it?
Upvotes: 1
Views: 133
Reputation: 168596
The literal answer to your question is to decode your original string using the raw_unicode_escape
codec.
In [2]: x = 'm\\u00e1s'
In [3]: x.decode('raw_unicode_escape')
Out[3]: u'm\xe1s'
But that's almost certainly the wrong way to do whatever you are actually trying to do.
Upvotes: 2