def _to_unicode(s):
try:<EOL><INDENT>return s.encode("<STR_LIT:ascii>")<EOL><DEDENT>except (UnicodeError, AttributeError):<EOL><INDENT>try:<EOL><INDENT>return s.decode("<STR_LIT:utf-8>")<EOL><DEDENT>except UnicodeError:<EOL><INDENT>return s<EOL><DEDENT><DEDENT>
decode a string as ascii or utf8 if possible (as required by the sftp
protocol).  if neither works, just return a byte string because the server
probably doesn't know the filename's encoding.