Re: encoding

David Kocher <[email protected]>
Newsgroups gmane.comp.java.sshtools.user
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just for the records.
- - I've modified all subclasses of  
com.sshtools.j2ssh.subsystem.SubsystemMessage in the package  
com/sshtools/j2ssh/sftp that call the method writeString of the  
ByteArrayWriter to encode the string first with UTF-8 (or any other  
encoding) before writing.
- - Also, in all calls to readString, I decode the string after reading.
- - In ByteArrayOutputStream the implementation of writeString has been  
changed from
	write(str.getBytes("US-ASCII"));
to
	 write(str.getBytes());

The changes are available at
http://sudo.ch/cgi-bin/viewcvs.cgi/cyberduck-cocoa/source/com/sshtools/ 
j2ssh/sftp/

My sftp client now even displays chinese characters in file listings :)

- --dk

On Jan 16, 2004, at 7:27 PM, David Kocher wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
> 	I've problems with J2SSH (in particular with filenames over SFTP)  
> with characters outside the ASCII range. I think I isolated the  
> problem to be in com.sshtools.j2ssh.io.ByteArrayWriter where in  
> writeString(String str) it decodes the supplied string using ASCII  
> encoding
>
>     public void writeString(String str) throws IOException {
>         if (str == null) {
>             writeInt(0);
>         } else {
>             writeInt(str.length());
>             write(str.getBytes("US-ASCII"));
>         }
>     }
>
> However, this raises a few questions:
> - - How do I determine the encoding of filenames from the remote  
> system to properly decode them to the encoding used on the client  
> system?
> - - Is it a good idea to encode every control statement with i.e.  
> ISO-8859-1 although this would be only needed with filenames (and  
> probably even has some side effects I might not be aware of)
> - - Should I rather do the encoding in the specific SubsystemMessage  
> messages in com.sshtools.sftp.* ?
>
> Any help appreciated
> - --dk
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (Darwin)
>
> iD8DBQFACC0tdBH4SdTFvT4RAi5/AJ47mp4CLZz/lnquUNPcBsryIieyGACcDP+T
> /GLyKrgPPLic8eTv4dT863Y=
> =p8m9
> -----END PGP SIGNATURE-----
>
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration
> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> http://www.eclipsecon.org/osdn
> _______________________________________________
> Sshtools-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sshtools-users
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFAEFmpdBH4SdTFvT4RApLOAJ4khe5H1ZYscgJnokAjOBnZiHeM3gCfbGrT
gV3YHwlPISJv3lgeiaiAvEc=
=GOOs
-----END PGP SIGNATURE-----



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.