thclpr
thclpr

Reputation: 5938

Converting string unicode to latin

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"

Upvotes: 0

Views: 739

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798744

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'

Upvotes: 1

Related Questions