Solved

Is there a statement in C# (using .Net Framework 4.0) that would convert an EBCDIC value to its DEC equivalent?

Posted on 2016-10-20
1
41 Views
Last Modified: 2016-10-24
I am writing a C# Console Application using VS2010 and .Net Framework 4.0.
I read a txt file as input.
I used the debugger to execute the following statement for 1 iteration of my application to read in the values for the 1st input record:

string[] readText = File.ReadAllLines(filePath, Encoding.UTF8);
           
            foreach (string s in readText)
            {
                Console.WriteLine(s);
            }

Then, from the Immediate Window, I executed the following query and got back the result:

? s[3]
38 '&'

Is there a statement I could issue in my C# application that would convert the EBCDIC value (which in this case is '&') into its DEC equivalent (which in this case is '80') ?

I see the translated values from "EBCDIC" to Dec in the following link:

http://www.longpelaexpertise.com/toolsCode.php
0
Comment
Question by:zimmer9
1 Comment
 
LVL 21

Accepted Solution

by:
JesterToo earned 500 total points
ID: 41853035
Have a look at the "Encoding" class in System.Text namespace.  The properties (there are several) of interest are probably "ASCII" and "Codepage".  I believe Codepage 037 is for EBCDIC.  The method to use in this class is "Convert".

If your EBCDIC data contains signed zoned decimal or packed decimal fields then you may need to handle them separately from the other potions of each record.  Blindly converting them from EBCDIC to ASCII will not result in correct values.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question