version 1.20, 2008/01/09 14:23:26
|
version 1.21, 2008/01/09 14:43:50
|
Line 21 fm_ns = 'http://www.filemaker.com/fmpxml
|
Line 21 fm_ns = 'http://www.filemaker.com/fmpxml
|
|
|
version_string = "V0.5.1 ROC 9.1.2008" |
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""" |
"""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 |
return None |
if not str: |
if not text: |
return u"" |
return u"" |
if type(str) is StringType: |
if isinstance(text, str): |
try: |
try: |
return str.decode('utf-8') |
return text.decode('utf-8') |
except: |
except: |
return str.decode('latin-1') |
return text.decode('latin-1') |
else: |
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""" |
"""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 |
return None |
if not str: |
if not text: |
return "" |
return "" |
if type(str) is StringType: |
if isinstance(text, str): |
return str |
return text |
else: |
else: |
return str.encode('utf-8') |
return text.encode('utf-8') |
|
|
def getTextFromNode(nodename): |
def getTextFromNode(nodename): |
"""get the cdata content of a node""" |
"""get the cdata content of a node""" |