Programming: Where can I find an ASCII Table?

  • Thread starter Thread starter carlodelmundo
  • Start date Start date
  • Tags Tags
    Programming Table
AI Thread Summary
The discussion centers on decoding binary ASCII codes into actual characters using C programming. A user sought a text file for an ASCII lookup table but was informed that a lookup table is unnecessary. Instead, the binary message can be separated into 8-bit chunks and directly converted to characters by casting the binary numbers to integers and then to characters. An example illustrates how to print characters using their hexadecimal equivalents. The conversation concludes with clarification on the conversion process, emphasizing the importance of correctly interpreting binary values.
carlodelmundo
Messages
133
Reaction score
0

Homework Statement



I am given the binary equivalent of ASCII codes and I am asked to decode a particular binary message (ASCII binary to actual ASCII character).

I am required to write it in C. Where can I get a text file of the ASCII code so I may create a look up table?

I googled, but I could not find a text file. And manually copying and pasting it into a document is not fun.

Thanks!
 
Physics news on Phys.org
I am not sure what your problem is. If you convert binary number to int and to char, it is already in ASCII.
 
You don't need a lookup table. Since what you start with already contains the ASCII codes for the characters in the message, all you need to do is separate the message into 8-bit chunks (bytes) and then print each one.

This code displays the character 'A'.
printf("%c", 0x41);

For example, if the ASCII string contains 43, 41, 54 (each in hex), printing them would result in C A T.
 
You mean if I have the following txt file:

Code:
01001001 01100110 00100000 01111001 01101111 01110101 00100000 01110111 
01100001 01101110 01110100 00100000 01101101 01101111 01110010 01100101 
00100000 01100101 01100110 01100110 01100101 01100011 01110100 01101001 
01110110 01100101 00100000 01110000 01110010 01101111 01100111 01110010

I am able to decode the messages just by casting them to chars?

EDIT: I see. I did the following:

Code:
printf("%c", 01000111);

It seems to have done the trick. Thanks
 
Not "just by casting". Your first number - 01001001 - is in fact 73 (dec). Convert it to a number and cast this number to char - and you will find it is "I".
 
Back
Top