def _unicode(string, encoding=None):
 if isinstance(string, compat.unicode):
  unicode_string = string
 elif isinstance(string, compat.bytes):
  if (encoding is None):
   encoding = sys.stdin.encoding
  if (encoding is None):
   encoding = locale.getpreferredencoding()
  unicode_string = string.decode(encoding, 'ignore')
 else:
  unicode_string = compat.unicode(string)
 return unicode_string.replace('\x00', '').strip()

def _unicode ( string , encoding = None ) : if isinstance ( string , compat . unicode ) : unicode_string = string elif isinstance ( string , compat . bytes ) : if ( encoding is None ) : encoding = sys . stdin . encoding if ( encoding is None ) : encoding = locale . getpreferredencoding ( ) unicode_string = string . decode ( encoding , 'ignore' ) else : unicode_string = compat . unicode ( string ) return unicode_string . replace ( '\x00' , '' ) . strip ( )
try to decode byte strings to unicode .