EBCDIC to Ascii conversion C#

10 pts.
Tags:
ASCII
C#
EBCDIC
Hi,

I am trying to convert EBCDIC to ASCII. The code which I used is converting the whole stream to ASCII however I am getting "????" for the missing characters..Is that because of double byte character set??

Can someone help me to resolve this issue??.

I tried with jon-skeet code as well but facing the same issue.

Thanks in advance.

Virbhadra.

 

 



Software/Hardware used:
C#

Answer Wiki

Thanks. We'll let you know when a new response is added.

Try this

public static byte[] ConvertAsciiToEbcdic(byte[] asciiData) 
{ 
	// Create two different encodings. 
	Encoding ascii = Encoding.ASCII; 
	Encoding ebcdic = Encoding.GetEncoding("IBM037"); //Retutn Ebcdic Data 
	return Encoding.Convert(ascii, ebcdic, asciiData); 
} 

public static byte[] ConvertEbcdicToAscii(byte[] ebcdicData) 
{ 
	// Create two different encodings. 
	Encoding ascii = Encoding.ASCII; 
	Encoding ebcdic = Encoding.GetEncoding("IBM037"); //Retutn Ascii Data 
	return Encoding.Convert(ebcdic, ascii, ebcdicData); 
}

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    Encoding ascii = Encoding.ASCII; ASCII might not be appropriate. UTF8Encoding might be better. The ASCII character set might not include everything. Encoding ebcdic = Encoding.GetEncoding("IBM037"); IBM037 should work for US English encoding. However, if this is DBCS or some more involved encoding, the 037 set probably won't work correctly. The actual encoding will need to be known. The encoding should either be sent with the file or data, or it should be agreed upon by the two sides of a conversation. Be aware that some cooperation may be needed between sending and receiving side. Practically speaking, an encoding such as UTF8 ought to be agreed upon by both sides before exchange of data. Sending encoded data without advertising the encoding scheme gets real messy. Tom
    125,585 pointsBadges:
    report
  • HajiTAG
    i have 2 textBoxes and 1 button. textbox1 has Ebcdis code i want that when i click on button textBox2 shows ascii code how will i do that???
    10 pointsBadges:
    report
  • Adamdavis
    That's helpful Tom. I was wondering about this as well.
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following