Skip to content

Instantly share code, notes, and snippets.

@rafaelgotts
Created July 16, 2015 17:40
Show Gist options
  • Select an option

  • Save rafaelgotts/9826b02dc99ff5da6ee2 to your computer and use it in GitHub Desktop.

Select an option

Save rafaelgotts/9826b02dc99ff5da6ee2 to your computer and use it in GitHub Desktop.
Exemplo de decodes para windows usando python
# coding: utf-8
# print_textos.py
import sys
# Aqui eu converto do utf-8 para unicode e depois para latin1 ou cp850
# Se fizer direto, ele tentará usar a tabela ascii e dai...
texto = "Olá code page 1252!".decode("utf-8").encode('latin1')
texto2 = "Olá code page 850!".decode("utf-8").encode('cp850')
# Print comum
print texto
print texto2
print '--------------'
# Usando stdout
sys.stdout.write(texto + "\n")
sys.stdout.write(texto2 + "\n")
sys.stdout.flush()
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment