I have the following string: s='T,Q0Z+QlT2ElT!A+Z,\u001B\u0003q' and would like to tell Python this is a Unicode string and have it converted to u'T,Q0Z+QlT2ElT!A+Z,\u001B\u0003q'
This does not work because the \ get escaped to \\:
In [29]: s = 'T,Q0Z+QlT2ElT!A+Z,\u001B\u0003q'
In [30]: u = unicode(s)
In [31]: u
Out[31]: u'T,Q0Z+QlT2ElT!A+Z,\\u001B\\u0003q'
Note s hasn't been prefixed with the u which is the source of the problem. My variable s is s = 'T,Q0Z+QlT2ElT!A+Z,\u001B\u0003q' and not s = u'T,Q0Z+QlT2ElT!A+Z,\u001B\u0003q'.
The result I want to get is u'T,Q0Z+QlT2ElT!A+Z,\u001B\u0003q' which is equal to u'T,Q0Z+QlT2ElT!A+Z,\x1B\x3q by the way.
Should be simple, but I'm struggling to find the solution. Thanks!
Edit: This is Python 2. I cannot add a u' before that string s because it comes to me that way... Obviously doing something like this s='u\'' +s won't work