FtpWebRequest in 2.0 Framework

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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,
 
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
 
Joerg Jooss,
We seem to be halfway there. I still don't understand how to decode a string.

Arne.
 
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?
 
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,
 
Back
Top