--- ZSQLExtend/importFMPXML.py 2008/01/09 14:23:26 1.20 +++ ZSQLExtend/importFMPXML.py 2008/02/04 19:06:34 1.22 @@ -19,32 +19,32 @@ except: fm_ns = 'http://www.filemaker.com/fmpxmlresult' -version_string = "V0.5.1 ROC 9.1.2008" +version_string = "V0.5.2 ROC 4.2.2008" -def unicodify(str, withNone=False): +def unicodify(text, withNone=False): """decode str (utf-8 or latin-1 representation) into unicode object""" - if withNone and str is None: + if withNone and text is None: return None - if not str: + if not text: return u"" - if type(str) is StringType: + if isinstance(text, str): try: - return str.decode('utf-8') + return text.decode('utf-8') except: - return str.decode('latin-1') + return text.decode('latin-1') else: - return str + return text -def utf8ify(str, withNone=False): +def utf8ify(text, withNone=False): """encode unicode object or string into byte string in utf-8 representation""" - if withNone and str is None: + if withNone and text is None: return None - if not str: + if not text: return "" - if type(str) is StringType: - return str + if isinstance(text, unicode): + return text.encode('utf-8') else: - return str.encode('utf-8') + return text def getTextFromNode(nodename): """get the cdata content of a node"""