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
45 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 22

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
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…

829 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