def _to_utf8(value):
 if isinstance(value, str):
  return value
 return value.encode('utf-8')

def _to_utf8 ( value ) : if isinstance ( value , str ) : return value return value . encode ( 'utf-8' )
encodes a unicode value to utf-8 if not yet encoded .