Discuss (FTP) and (SFTP, FTPS and SCP), our Java file transfer clients.
no avatar
User

Codon

Encoding Problem probably with EBCDIC

by Codon » Tue Oct 05, 2004 5:15 pm

First off, thank you for that easy to use ftp libary. Sadly, I have a strange problem. My Java Programm runs on a AIX and USS (which is a UNIX under a HOST) both with the IBM JDK. On the AIX I have no problems at all but on the USS everything works except for the encoding. Let me give a example:
I can connect from the USS to every FTP Server an even browse , but when I get a directory listing or a text file (which is ASCII), the econding is something I can not read.
If in the Directory are two files called: angemeldet.sh and blik. ftp.dir() will give me ??_?%????? and ?%?, .
I tried to convert these Strings with:

PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out, "Cp037")); //and "Cp850"

for (int i = 0; i < listing.length; i++) {
out.println(listing[i]);
}

out.flush();

but I had no luck. The most strange is, that when I download a Text File it has the same unreadable Information, but when I upload it again it converts back to normal ASCII. Magic!

If you have any Idea how get this encoding problem fixed please let me know. How can I find out which encoding ist ??_?%????? ?

Greetings and thanks Codon
no avatar
User

Codon

by Codon » Tue Oct 05, 2004 7:26 pm

After trying a lot of stuff (and learning about encoding conversion :-) ), i come to the conclusion that there is a bug in the IBM Virtual Machine on the USS. The transformation of encodings is probably not implementet. Once you got EBCDIC encoding you can not conevrt it bach to ASCII on the IBM VM on USS.
So the only workaround is to modify the InputStreamReader and give it a fixed encoding. Off Course yau have to modify the ASCII get/put Methods analog to this if you wish to use them:

Class: FTPClient
Method: public String[] dir(String dirname, boolean full)

Code:
...
LineNumberReader in =new LineNumberReader(
new InputStreamReader(data.getInputStream(),"Cp850"));
...

I know its a ugly workaround, but thats the only way to get it run under a USS.

Greetings Codon
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Tue Oct 05, 2004 7:45 pm


Who is online

Users browsing this forum: No registered users and 22 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign