Plus de problemes d'encodage a l'affichage.
darcs-hash:20071216181122-af139-84bbee3dedcea716bd9d2db0aaa460dd309789cf.gz
This commit is contained in:
parent
0265113025
commit
8bfc336f8f
1 changed files with 12 additions and 1 deletions
|
@ -106,8 +106,19 @@ OK = coul('OK', 'vert')
|
||||||
WARNING = coul('WARNING', 'jaune')
|
WARNING = coul('WARNING', 'jaune')
|
||||||
ERREUR = coul('ERREUR', 'rouge')
|
ERREUR = coul('ERREUR', 'rouge')
|
||||||
|
|
||||||
|
def to_encoding(txt, enc=encoding):
|
||||||
|
if type(txt) == unicode:
|
||||||
|
return txt.encode(enc)
|
||||||
|
else:
|
||||||
|
# On suppose d'abord que le texte est en UTF-8
|
||||||
|
try:
|
||||||
|
return txt.decode("UTF-8").encode(enc)
|
||||||
|
except:
|
||||||
|
# Sinon c'est surement de l'iso
|
||||||
|
return txt.decode("ISO8859-15").encode(enc)
|
||||||
|
|
||||||
def cprint(txt, col='blanc', newline=True):
|
def cprint(txt, col='blanc', newline=True):
|
||||||
t = coul(txt.encode(encoding), col)
|
t = coul(to_encoding(txt), col)
|
||||||
if newline:
|
if newline:
|
||||||
print t
|
print t
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue