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
35 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now