--- MPIWGWeb/Attic/MPIWGHelper.py 2009/11/06 15:37:42 1.1.2.9 +++ MPIWGWeb/Attic/MPIWGHelper.py 2010/02/10 18:25:44 1.1.2.10 @@ -84,27 +84,27 @@ def sortI(x,y): return cmp(x[1],y[1]) -def unicodify(str): +def unicodify(s): """decode str (utf-8 or latin-1 representation) into unicode object""" #logging.error("unicodify: %s"%str) - if not str: - return "" - if type(str) is StringType: + if not s: + return u"" + if isinstance(s, str): try: - return str.decode('utf-8') + return s.decode('utf-8') except: - return str.decode('latin-1') + return s.decode('latin-1') else: - return str + return s -def utf8ify(str): +def utf8ify(s): """encode unicode object or string into byte string in utf-8 representation""" - if not str: + if not s: return "" - if type(str) is StringType: - return str + if isinstance(s, str): + return s else: - return str.encode('utf-8') + return s.encode('utf-8') def shortenString(s, l, ellipsis='...'):