--- ZSQLExtend/importFMPXML.py 2008/01/09 14:23:26 1.20 +++ ZSQLExtend/importFMPXML.py 2008/01/09 14:43:50 1.21 @@ -21,30 +21,30 @@ fm_ns = 'http://www.filemaker.com/fmpxml version_string = "V0.5.1 ROC 9.1.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, str): + return text else: - return str.encode('utf-8') + return text.encode('utf-8') def getTextFromNode(nodename): """get the cdata content of a node"""