diff --git a/gestion/affich_tools.py b/gestion/affich_tools.py index 03abe030..132871e9 100755 --- a/gestion/affich_tools.py +++ b/gestion/affich_tools.py @@ -106,8 +106,19 @@ OK = coul('OK', 'vert') WARNING = coul('WARNING', 'jaune') 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): - t = coul(txt.encode(encoding), col) + t = coul(to_encoding(txt), col) if newline: print t else: