From 09662b7e573ccd509c22231133cb22731aa7a792 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Wed, 14 Jan 2009 12:48:27 +0100 Subject: [PATCH] [affich-tools] On evite de mourir pour une erreur d'encodage darcs-hash:20090114114827-ffbb2-f440d23772724939fe41750b5547717c8b74c39e.gz --- gestion/affich_tools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gestion/affich_tools.py b/gestion/affich_tools.py index 6133ab24..cf111474 100755 --- a/gestion/affich_tools.py +++ b/gestion/affich_tools.py @@ -105,14 +105,14 @@ ERREUR = coul('ERREUR', 'rouge') def to_encoding(txt, enc=encoding): if type(txt) == unicode: - return txt.encode(enc) + return txt.encode(enc, 'ignore') else: # On suppose d'abord que le texte est en UTF-8 try: - return txt.decode("UTF-8").encode(enc) + return txt.decode("UTF-8").encode(enc, 'ignore') except: # Sinon c'est surement de l'iso - return txt.decode("ISO8859-15").encode(enc) + return txt.decode("ISO8859-15").encode(enc, 'ignore') def cprint(txt, col='blanc', newline=True): t = coul(to_encoding(txt), col)