version 1.1.2.9, 2009/11/06 15:37:42
|
version 1.1.2.10, 2010/02/10 18:25:44
|
Line 84 def sortI(x,y):
|
Line 84 def sortI(x,y):
|
return cmp(x[1],y[1]) |
return cmp(x[1],y[1]) |
|
|
|
|
def unicodify(str): |
def unicodify(s): |
"""decode str (utf-8 or latin-1 representation) into unicode object""" |
"""decode str (utf-8 or latin-1 representation) into unicode object""" |
#logging.error("unicodify: %s"%str) |
#logging.error("unicodify: %s"%str) |
if not str: |
if not s: |
return "" |
return u"" |
if type(str) is StringType: |
if isinstance(s, str): |
try: |
try: |
return str.decode('utf-8') |
return s.decode('utf-8') |
except: |
except: |
return str.decode('latin-1') |
return s.decode('latin-1') |
else: |
else: |
return str |
return s |
|
|
def utf8ify(str): |
def utf8ify(s): |
"""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 not str: |
if not s: |
return "" |
return "" |
if type(str) is StringType: |
if isinstance(s, str): |
return str |
return s |
else: |
else: |
return str.encode('utf-8') |
return s.encode('utf-8') |
|
|
|
|
def shortenString(s, l, ellipsis='...'): |
def shortenString(s, l, ellipsis='...'): |