changeset 553:2fe04b61ed95

make sure unicodify and utf8ify return str and unicode.
author casties
date Mon, 24 Sep 2012 16:24:22 +0200
parents 13eb36c0b00c
children c56bc63436de
files SrvTxtUtils.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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"""