Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def conv_ascii(text,context):
- """Convierte vocales accentuadas, ñ y ç a sus caracteres equivalentes ASCII"""
- old_chars = ['á','é','í','ó','ú','à','è','ì','ò','ù','ä','ë','ï','ö','ü','â','ê','î', \
- 'ô','û','Á','É','Í','Ú','Ó','À','È','Ì','Ò','Ù','Ä','Ë','Ï','Ö','Ü','Â','Ê','Î',\
- 'Ô','Û','ñ','Ñ','ç','Ç','ª','º', chr(176), chr(0xb0)
- ]
- new_chars = ['a','e','i','o','u','a','e','i','o','u','a','e','i','o','u','a','e','i','o',\
- 'u','A','E','I','O','U','A','E','I','O','U','A','E','I','O','U','A','E','I','O','U','n',\
- 'N','c','C','a','o', 'o','o'
- ]
- print "contexxxxxxxxxxxxxxrt",context
- print "...............", text
- for old, new in zip(old_chars, new_chars):
- try:
- text = text.replace(unicode(old,'UTF-8'), new)
- except:
- # text = text.replace(old, new)
- # text = "ERROR DE CODIFICACION ID"
- print "...............", text
- return text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement