943,960 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 5005
  • C RSS
Oct 16th, 2008
0

Algorithm for EBCDIC to ASCII Conversion

Expand Post »
Hello,

The Hexadecimal value of EBCDIC has to be converted to corresponding character as the user inputs it.

The following table shows the hexadecimal value of characters in ASCII and EBCDIC.
Can anybody help me with an efficient C-Algorithm for this conversion?

Char----Deci-------Hex.ASCII---Hex.EBCDIC
A ------65---------41------------- C1
B-------66---------42-------------C2
C-------67---------43-------------C3
D-------68 ---------44-------------C4
E-------69----------45-------------C5
F-------70----------46-------------C6

Thank you very much in advance.

Regards,
Sahana
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smnadig is offline Offline
11 posts
since Aug 2008
Oct 16th, 2008
0

Re: Algorithm for EBCDIC to ASCII Conversion

You could write your hex-to-deci function, and then you can simply write
char a = hex-to-deci-function(hex_num)
Reputation Points: 110
Solved Threads: 43
Posting Whiz in Training
Sci@phy is offline Offline
279 posts
since Sep 2008
Oct 16th, 2008
1

Re: Algorithm for EBCDIC to ASCII Conversion

>Can anybody help me with an efficient C-Algorithm for this conversion?
printf directly supports printing characters, decimal, and hexadecimal, so that's easy. Converting between ASCII and EBCDIC is also easy and highly efficient if you use two conversion tables:
  1. unsigned char ascii[] = {
  2. /* All characters in ASCII */
  3. };
  4.  
  5. unsigned char ebcdic[] = {
  6. /* All characters in EBCDIC */
  7. };
  8.  
  9. unsigned char to_ascii ( unsigned char c )
  10. {
  11. return ascii[c];
  12. }
  13.  
  14. unsigned char to_ebcdic ( unsigned char c )
  15. {
  16. return ebcdic[c];
  17. }
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Dec 29th, 2008
0

Re: Algorithm for EBCDIC to ASCII Conversion

Thank you.

Regards,
Sahana
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smnadig is offline Offline
11 posts
since Aug 2008
Dec 30th, 2008
0

Re: Algorithm for EBCDIC to ASCII Conversion

Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Need help changing the address of an array
Next Thread in C Forum Timeline: Problem Creating Window





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC