0

I have the following result from some http requests:

 Tratamento\ da\ rejei\u00E7\u00E3o\ no\ cancelamento\ da\ desagrega\u00E7\u00E3o

i did some research and i was able to find this line of code, wich can convert utf-16 with the following line of code :

print unicode(u"\u00e3".encode("latin-1"), "latin-1")

My problem is, how i can convert a hole sentence of results from utf-16 to latin-1 ? Being more especific, how can convert or replace it to: "Tratamento da rejeição no cancelamento da desagragação"

thclpr
  • 5,778
  • 10
  • 54
  • 87

1 Answers1

1

Pass the whole string.

>>> u'Tratamento\ da\ rejei\u00E7\u00E3o\ no\ cancelamento\ da\ desagrega\u00E7\u00E3o'.encode('latin-1')
'Tratamento\\ da\\ rejei\xe7\xe3o\\ no\\ cancelamento\\ da\\ desagrega\xe7\xe3o'
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358