Hi!

I've to solve an interesting interop project. I get a byte stream or a
byte array which contains the unmanaged memory representation of a
structure like

struct MyStruct {
  short a;
  byte b;
  char c[10];
  ...
};

This structure comes from a mainframe what means that numeric values are
in big-endian format and characters are in EBCDIC encoding. How can I
translate this byte stream to a managed struct or class?

My attempt is to

1. extract the bytes for a structure field from the stream
2. swap the bytes to little-endian for numeric fields and use
System.BitConverter.Toxxx to convert the bytes to an instance of a managed
type
3. convert characters with an EbcdicEncoding class to a managed string
4. populate a managed struct or class field by field

Do you know a more elegant or simpler solution?

So long ...

Torsten

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

Guerrilla .NET, 8 Dec 2003, in Los Angeles
http://www.develop.com/courses/gdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to