Hi,

   +-From: "Oberhuber, Martin" <[EMAIL PROTECTED]> --
   |_Date: Fri, 28 Sep 2007 21:44:59 +0200 __
   |
   |Hm, that's a good question, I'm not sure. I guess I'd probably
   |not keep such a database, and use "UTF-8" as the encoding to
   |use by default; so users would override it only if they see 
   |strange unwanted effects. Basically, not put in any magic 
   |but have the user manually specify the encoding if they 
   |don't like the results they have with UTF-8.

Humm, so if sftpd has been correctly implemented, there are
possibilities that sftpd may receive the invalid data. It is not good.  
We should respect for the protocol.

In these days, I have been seeking the solution for almost of all,
and I have found one solution.

There is the concept, the version number for the sftp protocol.
It seems that the latest version is 6 and it has been defined in 
  draft-ietf-secsh-filexfer-13[1].

According to its changes, the UTF-8 filename had been introduced
at version 4.  This means that the encoding for filenames
had not been defined until version 3.  The current jsch's sftp
client is based on sftp protocol version 3.  
# FYI, the latest OpenSSH's sftp client and server have also been based 
# on version 3.

So, I'll plan to add the following method to ChannelSftp,

  public void setFilenameEncoding(String encoding) throws SftpException{
    int sversion=getVersion();
    if(sversion > 3 &&
       !encoding.equals("UTF-8")){
      throw new SftpException(SSH_FX_FAILURE, "....");
    }
    fEncoding=encoding;
  }

and you can use it as follows,

      session.connect();
      Channel cSftphannel=(ChannelSftp)session.openChannel("sftp");
      channel.connect();
      try{
        channel.setFilenameEncoding("SJIS");
      }
      catch(SftpException e){
        // ...
      }

[1] http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13


Sincerely,
--
Atsuhiko Yamanaka
JCraft,Inc.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Tel +81-22-723-2150
    +1-415-578-3454
Fax +81-22-224-8773
Skype callto://jcraft/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to