def unicodeencode(value, encoding=None):
 retVal = value
 if isinstance(value, unicode):
  try:
   retVal = value.encode((encoding or UNICODE_ENCODING))
  except UnicodeEncodeError:
   retVal = value.encode(UNICODE_ENCODING, 'replace')
 return retVal

def unicodeencode ( value , encoding = None ) : retVal = value if isinstance ( value , unicode ) : try : retVal = value . encode ( ( encoding or UNICODE_ENCODING ) ) except UnicodeEncodeError : retVal = value . encode ( UNICODE_ENCODING , 'replace' ) return retVal
returns 8-bit string representation of the supplied unicode value .