Changeset 514:c55e376be01b in documentViewer for SrvTxtUtils.py
- Timestamp:
- Feb 28, 2012, 6:46:37 PM (12 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SrvTxtUtils.py
r490 r514 12 12 13 13 14 srvTxtUtilsVersion = "1. 3"14 srvTxtUtilsVersion = "1.4" 15 15 16 16 def getInt(number, default=0): … … 27 27 except: 28 28 return default 29 30 def unicodify(s): 31 """decode str (utf-8 or latin-1 representation) into unicode object""" 32 if not s: 33 return u"" 34 if isinstance(s, str): 35 try: 36 return s.decode('utf-8') 37 except: 38 return s.decode('latin-1') 39 else: 40 return s 41 42 def utf8ify(s): 43 """encode unicode object or string into byte string in utf-8 representation. 44 assumes string objects to be utf-8""" 45 if not s: 46 return "" 47 if isinstance(s, str): 48 return s 49 else: 50 return s.encode('utf-8') 29 51 30 52 def getText(node, recursive=0):
Note: See TracChangeset
for help on using the changeset viewer.