# HG changeset patch # User casties # Date 1348496662 -7200 # Node ID 2fe04b61ed95a28f5419c92945be1dad22c4621e # Parent 13eb36c0b00cb3afc658310f6712572b59548cff make sure unicodify and utf8ify return str and unicode. diff -r 13eb36c0b00c -r 2fe04b61ed95 SrvTxtUtils.py --- a/SrvTxtUtils.py Wed Sep 19 10:37:38 2012 +0200 +++ b/SrvTxtUtils.py Mon Sep 24 16:24:22 2012 +0200 @@ -11,7 +11,7 @@ import logging -srvTxtUtilsVersion = "1.5" +srvTxtUtilsVersion = "1.5.1" def getInt(number, default=0): """returns always an int (0 in case of problems)""" @@ -37,17 +37,17 @@ except: return s.decode('latin-1') else: - return s + return unicode(s) def utf8ify(s): """encode unicode object or string into byte string in utf-8 representation. assumes string objects to be utf-8""" if not s: return "" - if isinstance(s, str): - return s + if isinstance(s, unicode): + return s.encode('utf-8') else: - return s.encode('utf-8') + return str(s) def getText(node, recursive=0): """returns all text content of a node and its subnodes"""