EBCDIC to byte array

  • Thread starter Thread starter Arne Garvander
  • Start date Start date
A

Arne Garvander

How do I translate a string with EBCDIC characters into a byte array?
A VB 8 solution is prefered.
I have tried code page 37, but it will mess up half of my characters.
Dim Encoding37 As Encoding = Encoding.GetEncoding(37)
 
Jon,
Not all IBM computers in the US has the same EBCDIC character set. Character
maps found on the web are often wrong. I have painstakingly created my own
character maps. I can translate from ASCII to EBCDIC using a byte array that
is not in .Net. Now I am trying to support a .Net byte array.
I am studying your source code trying to find out how create a byte array.
I am afraid to use your character maps since I need to support all the keys
on the keyboard. Special characters are used in password and need to match
special characters use on the mainframe.
--
Arne Garvander
Certified Geek
Professional Data Dude
 
Arne Garvander said:
Not all IBM computers in the US has the same EBCDIC character set. Character
maps found on the web are often wrong. I have painstakingly created my own
character maps. I can translate from ASCII to EBCDIC using a byte array that
is not in .Net. Now I am trying to support a .Net byte array.
I am studying your source code trying to find out how create a byte array.
I am afraid to use your character maps since I need to support all the keys
on the keyboard. Special characters are used in password and need to match
special characters use on the mainframe.

Well, you can easily create your own map with the same format as my
code reads, and build your own version of my encoding.
 
How do I translate a string with EBCDIC characters into a byte array?
A VB 8 solution is prefered.
I have tried code page 37, but it will mess up half of my characters.
Dim Encoding37 As Encoding = Encoding.GetEncoding(37)

All strings are Unicode.
If that thing is EBCDIC, then it is a byte array already.
If somehow it ended up stored in a string, it is wrong, and trying to convert
it to something else might do more harm than good.
 
OK, we might have used strings by mistake. Unfortunately you can't use a
string in a webrequest, so I convert my strings to a byte array, byte array
to a stream and then I do a mainframe http request. The data comes backs as
an EBCDIC stream, converts to byte array and then to EBCDIC string.
I have a mess.
--
Arne Garvander
Certified Geek
Professional Data Dude
 
If you keep the array in binary, you can set up maps for various different
EBCDIC encodings. You also have to watch for packed characters in the IBM
world. I may have some code I worked on a few years ago in .NET. If I can
find it, I will post the methodology.

If you are focused on SQL Server, Patrick Altman and Ben Harrell wrote an
SSIS plug in that does the conversion.

BTW, if you do not know the maps, you can run a sample of the EBCDIC through
different mappings and determine which one has the least number of garbage
characters. This will not help with packed characters, but it will make
things readable. Ultimately, someone needs to map fields when you are
converting from EBCDIC, especially if you are working with various clients.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
 
OK, we might have used strings by mistake. Unfortunately you can't use a
string in a webrequest, so I convert my strings to a byte array, byte array
to a stream and then I do a mainframe http request. The data comes backs as
an EBCDIC stream, converts to byte array and then to EBCDIC string.
I have a mess.
My guess is that the byte array you get from the server (thru the stream)
is EBCDIC. So try converting that to a string (with the GetChars member
of the Decoder class)
 
Back
Top