Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > Convert EBCDIC to ASCII
 

Convert EBCDIC to ASCII

i have a text file that orignated on an IBM mainFrame. the file contains numeric data as follows:

00439N.

The above value should be -04395. I'm having problems making this conversion happen are there anu methods in the framework that will help me with this.

thanks

Louisb  Wednesday, May 24, 2006 5:01 PM

A few useful links dealing with EBCDIC encoding in .NET

http://www.eggheadcafe.com/articles/20030521.asp

http://www.stringx.com/

http://www.yoda.arachsys.com/csharp/ebcdic/

These deal with ASCII to EBCDIC and vice versa

spotty  Wednesday, May 24, 2006 5:54 PM
Thanks Spotty,

I was looking for the solution, seems given solution will work but need to test.


Ashish Khandelwal
http://ashishkhandelwal.arkutil.com
Ashish Khandelwal http://ashishkhandelwal.arkutil.com
Ashish Khandelwal  Thursday, November 26, 2009 7:40 AM
That format appears to be what is called EBCDIC Zone-Decimal. In that format,the sign digit isb1101nnnn or b11010101for your example which is N in EBCDIC. The other digits are b1111nnnn. The following code simply uses the lower four digits to extract the decimal value, and tests the last digit for the sign. You will need to get each intput value into an array of char to use this code. The stringToChArarray function is probably suitable, as I presume your input file is being read as strings.

        Dim Inarray() As Char = {Chr(&HF0), Chr(&HF0), Chr(&HF4), Chr(&HF3), Chr(&HF9), Chr(&HD5)}
        'Dim Inarray() As Char = {Chr(&HF0), Chr(&HF0), Chr(&HF4), Chr(&HF3), Chr(&HF9), Chr(&HF5)}
        Dim sign As Integer = 1
        Dim R As Long = 0
        For I As Integer = 0 To inarray.length - 1
            Dim c As Integer = Asc(Inarray(I))
            If I = Inarray.Length - 1 Then
                If (c And &HF0) = &HD0 Then sign = -1 Else sign = 1
            End If
            c = c And &HF
            R = R * 10 + c
        Next
        R *= sign
        MsgBox(R.ToString)



Acamar  Thursday, November 26, 2009 9:43 AM

You can use google to search for other answers

Custom Search

More Threads

• 10msec timing accuracy in vb.net program
• Remoteendpoint.tostring does not return same port connection is made on.
• Form.Load question
• How can I update the dll file, the UserControl???
• Convert C# to VB 2005 - Problem using inpout32.dll
• XML dialogue
• Check Whether The Barcode Reader Read A Barcode
• webbrowser ftp
• Directory Sercher
• Using a picture for loading