Algorithm for EBCDIC to ASCII Conversion

Thread Solved

Join Date: Aug 2008
Posts: 11
Reputation: smnadig is an unknown quantity at this point 
Solved Threads: 0
smnadig smnadig is offline Offline
Newbie Poster

Algorithm for EBCDIC to ASCII Conversion

 
0
  #1
Oct 16th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 273
Reputation: Sci@phy will become famous soon enough Sci@phy will become famous soon enough 
Solved Threads: 42
Sci@phy's Avatar
Sci@phy Sci@phy is offline Offline
Posting Whiz in Training

Re: Algorithm for EBCDIC to ASCII Conversion

 
0
  #2
Oct 16th, 2008
You could write your hex-to-deci function, and then you can simply write
char a = hex-to-deci-function(hex_num)
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,596
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 712
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Algorithm for EBCDIC to ASCII Conversion

 
0
  #3
Oct 16th, 2008
>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. }
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 11
Reputation: smnadig is an unknown quantity at this point 
Solved Threads: 0
smnadig smnadig is offline Offline
Newbie Poster

Re: Algorithm for EBCDIC to ASCII Conversion

 
0
  #4
Dec 29th, 2008
Thank you.

Regards,
Sahana
Thanks & Regards
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Algorithm for EBCDIC to ASCII Conversion

 
0
  #5
Dec 30th, 2008
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC