python - ascii codec can't encode character -


i'm trying create string special characters portuguese-brazil (e.g. á, à, â, ç)

push_message = 'á' push_message.decode().encode('utf-8') 

but i'm getting error:

unicodeencodeerror: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128) 

i need send parse api, , parse api allows utf8 encoding. can solve this?

edit

when try

push_message.decode('utf-8') 

i get

unicodeencodeerror: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128) 

when try

push_message.decode('latin-1') 

i get

unicodeencodeerror: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128) 

it worked this:

unicode(push_message.decode('utf-8'))  

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -