Results 1 to 11 of 11

Thread: Convert EBCDIC to ASCII format

  1. #1

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651

    Convert EBCDIC to ASCII format

    Hi

    I have a print file that has been generated from an IBM AS/400 system. I need to convert the EBCDIC format file into ASCII format. Is there any method in .NET framework that I can use to easily convert my file. I'm using VB.NET. If I have to write my own conversion function can someone give me a few ideas please.

    Thanks
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  2. #2

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651
    Anyone please?
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  4. #4

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651
    Thanks dynamic_sysop.

    Unfortunately the Microsoft link is not very helpful. I have also realised that I cannot read my EBCDIC file as a text file. In VB6 I using the TextStream from FileSystemObject to read 133 characters (represneting a line) into a string and then passing that string to a library method for conversion.

    My problem is two fold.

    1. I have a VB6 library which I can reference from my VB.NET app but I need to pass it a string.
    2. I can't read my EBCDIC file as a text file. ReadLine methods fail.

    Any suggestions of how to tackle this.

    Thanks
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  5. #5
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    i dont know what format EBCDIC is personally , but you can read most stuff with streamreader, whether the chars return correctly from the opened file depends what you are opening i think but streamreader might allow you to read your file.
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  6. #6

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651
    dynamic_sysop

    EBCDIC is the proprietary IBM format. I did try using StreamReader but unfortunately when I convert the characters read into a string it doesn't come in the format that I expect to pass it on to the VB6 conversion library. I'm probably not giving the right encoding mode while opening the stream and can't figure it out either. I have for the moment opted for a dirty solution which is my last resort and I'll try it tomorrow at the office. I've decided to reference the Scripting.FileSystemObject class (SCRRUN.DLL) in my VB.NET project and then use the Read method of the TextStream to read my EBCDIC file. I hate this solution as I would prefer avoiding any VB6 code in my project.

    Thanks for your help.
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  7. #7
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    you know you could reference a vb6 dll to your programme and then do your decoding stuff inside the dll , i'm sure you are aware it's very easy to create a vb6 dll , i've built quite a few and referenced them to vb.net ( eg: i find winsock to be rubish , so i built my own custom socket connection through api , i reference that to .net and then all the coding / converting is done inside the vb6 dll ).
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  8. #8

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651
    Thanks for your input dynamic_sysop.

    Here's how I resolved my problem.

    1. Reference the SCRRUN.DLL and instantiate the FileSystemObject class.
    2. Reference the VB6 DLL which converts EBCDIC to ASCII
    3. Open the file using TextStream
    4. Read each fixed record size using oTxtStream.Read(recsize) into a string strEBCDIC
    5. Invoke the conversion using
    strASCII = objStrLib.EBCDCI2ASCII(strEBCDIC)
    And it works now.

    In fact I had resolved myself to using the VB6 library but then got stuck on correctly reading the EBCDIC records into a string. After trying all VB.NET streams, various Encoding modes etc. I still couldn't get the correct data in my string variable.

    I am still going to do some research and find out the exact equivalent of FSO TextStream.Read in the .NET environment.

    Thanks again for your posts.
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  9. #9
    Lively Member
    Join Date
    May 2001
    Posts
    95

    What is the VB6 dll called

    Hey I am having the same issue. I can find the SCCRUN.DLL but I am not sure what the VB6.DLL is called .

    Any help would be appreciated

  10. #10

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651
    Hi

    Haven't dug further yet but I'm sure the answer lies in proper usage of the StreamReader, BinaryStream etc. How, don't know yet :-(
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  11. #11
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    well you could try using the encoding class with encoding.convert , eg:
    VB Code:
    1. Dim source As Encoding = Encoding.GetEncoding(37)'///EBCDIC encoding.
    2.         Dim path As Encoding = Encoding.ASCII
    3.         Dim b As Byte() = path.GetBytes(TextBox1.Text.ToCharArray)
    4.         Dim aB As Byte() = Encoding.Convert(source, path, b)
    5.  
    6.         Console.WriteLine(path.GetString(aB))
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width