def get_valid_utf8_str(str_or_unicode):
 if isinstance(str_or_unicode, unicode):
  (str_or_unicode, _len) = utf8_encoder(str_or_unicode, 'replace')
 (valid_utf8_str, _len) = utf8_decoder(str_or_unicode, 'replace')
 return valid_utf8_str.encode('utf-8')

def get_valid_utf8_str ( str_or_unicode ) : if isinstance ( str_or_unicode , unicode ) : ( str_or_unicode , _len ) = utf8_encoder ( str_or_unicode , 'replace' ) ( valid_utf8_str , _len ) = utf8_decoder ( str_or_unicode , 'replace' ) return valid_utf8_str . encode ( 'utf-8' )
get valid parts of utf-8 str from str .