RSS Forums RSS

Algorithm for EBCDIC to ASCII Conversion

Please support our C advertiser: Programming Forums
Thread Solved
Reply
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

  #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
AddThis Social Bookmark Button
Reply With Quote  
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

  #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  
Posts: 7,460
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: 676
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Algorithm for EBCDIC to ASCII Conversion

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

  #4  
Dec 29th, 2008
Thank you.

Regards,
Sahana
Thanks & Regards
Reply With Quote  
Posts: 2,000
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: 331
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Algorithm for EBCDIC to ASCII Conversion

  #5  
Dec 30th, 2008
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the C Forum
Views: 1326 | Replies: 4 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:19 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC