FtpWebRequest in 2.0 Framework

G

Guest

Has anyone tried to download a mainframe file with FtpWebRequest. It doesn't
seem to translate from EBCDIC to ASCII.
The old inet control in VB6 has the same problem.
Command line FTP has no problem to translate from EBCDIC to ASCII, but I
prefer a .Net assembly.
 
J

Joerg Jooss

Arne said:
Has anyone tried to download a mainframe file with FtpWebRequest. It
doesn't seem to translate from EBCDIC to ASCII.
The old inet control in VB6 has the same problem.
Command line FTP has no problem to translate from EBCDIC to ASCII,
but I prefer a .Net assembly.

Why can't you download it as binary and use System.Text.Encoding to
convert from EBCDIC? Windows supports tons of EBCDIC encodings -- see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/un
icode_81rn.asp.


Cheers,
 
G

Guest

Joerg Jooss,
I tried your link and I got 'Location Cannot Be Found'. I have looked at
System.Text.Encoding, but I have not found anything on EBCDIC yet.

Arne
 
G

Guest

Joerg Jooss,
We seem to be halfway there. I still don't understand how to decode a string.

Arne.
 
G

Guest

Joerg Jooss,
The Microsoft way
Dim e37 As Encoding
Dim ascii As Encoding
e37 = Encoding.GetEncoding(37)
ascii = Encoding.ASCII
Dim asciiBytes As Byte() = Encoding.Convert(e37, ascii, encoded)
Dim asciiChars(ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)) As
Char
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)
buf = New String(asciiChars)

The Jon way
Dim ebc As EbcdicEncoding
ebc = EbcdicEncoding.GetEncoding("EBCDIC-US")
buf = ebc.GetString(encoded)

Is there an easier way?
 
J

Joerg Jooss

Arne said:
Joerg Jooss,
The Microsoft way
Dim e37 As Encoding
Dim ascii As Encoding
e37 = Encoding.GetEncoding(37)
ascii = Encoding.ASCII
Dim asciiBytes As Byte() = Encoding.Convert(e37, ascii, encoded)
Dim asciiChars(ascii.GetCharCount(asciiBytes, 0,
asciiBytes.Length)) As Char
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)
buf = New String(asciiChars)

The Jon way
Dim ebc As EbcdicEncoding
ebc = EbcdicEncoding.GetEncoding("EBCDIC-US")
buf = ebc.GetString(encoded)

Is there an easier way?

There's no MS way, nor is there a Jon way. All implementations are
derived from the base class System.Text.Encoding, thus you can use
GetString() in the first example as well.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top