Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A = "Diga sí por cualquier número de otro cuidador.".encode("utf-8")
- # -*- coding: utf-8 -*-
- A = u"Diga sí por cualquier número de otro cuidador.".encode("utf-8")
- A = u"Diga sí por cualquier número de otro cuidador.".encode("utf-8")
- # -*- coding: utf-8 -*-
- Preliminaries:
- >>> import unicodedata
- >>> unicodedata.name(u'xed')
- 'LATIN SMALL LETTER I WITH ACUTE'
- >>> uc = u'Diga sxed por'
- What happens if file is encoded in UTF-8:
- >>> infile = uc.encode('utf8')
- >>> infile
- 'Diga sxc3xad por'
- >>> infile.encode('utf8')
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128)
- #### NOT the message reported in the question ####
- What happens if file is encoded in cp1252 or latin1 or similar:
- >>> infile = uc.encode('cp1252')
- >>> infile
- 'Diga sxed por'
- >>> infile.encode('utf8')
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xed in position 6: ordinal not in range(128)
- #### As reported in the question ####
- # Encoding: UTF-8
- >> type(u"zażółć gęślą jaźń")
- -> <type 'unicode'>
- >> type("zażółć gęślą jaźń")
- -> <type 'str'>
- u"Diga sí por cualquier número de otro cuidador.".encode("utf-8")
- # -*- coding: utf-8 -*-
Add Comment
Please, Sign In to add comment