# HG changeset patch # User casties # Date 1423671503 -3600 # Node ID 447251b5af6581bd5187173feb2524aaa521915a # Parent 98fe8e168c0178b7fd78917b0e4d6c843297d4ae make sure utf8ify and unicodify output text. diff -r 98fe8e168c01 -r 447251b5af65 SrvTxtUtils.py --- a/SrvTxtUtils.py Mon Dec 15 17:59:59 2014 +0100 +++ b/SrvTxtUtils.py Wed Feb 11 17:18:23 2015 +0100 @@ -22,7 +22,7 @@ import xml.etree.ElementTree as ET -srvTxtUtilsVersion = "1.13" +srvTxtUtilsVersion = "1.13.1" map_months = {'en': [u"", u"January", @@ -94,18 +94,22 @@ return s.decode('utf-8') except: return s.decode('latin-1') + elif isinstance(s, unicode): + return s 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): + if isinstance(s, unicode): + return s.encode('utf-8') + elif isinstance(s, str): return s else: - return s.encode('utf-8') + return str(s) def getTextFromNode(node, recursive=False, length=0):