Created
August 7, 2017 05:38
-
-
Save thomasjao/ef6a379733e5c8365a0a14256c6dcbb4 to your computer and use it in GitHub Desktop.
Generate ASCII Table in 4 columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) | |
{ | |
int i, col, code; | |
char* char_name[32]; | |
char_name[0] = "NUL"; | |
char_name[1] = "SOH"; | |
char_name[2] = "STX"; | |
char_name[3] = "ETX"; | |
char_name[4] = "EOT"; | |
char_name[5] = "ENQ"; | |
char_name[6] = "ACK"; | |
char_name[7] = "BEL"; | |
char_name[8] = "BS"; | |
char_name[9] = "TAB"; | |
char_name[10] = "LF"; | |
char_name[11] = "VT"; | |
char_name[12] = "FF"; | |
char_name[13] = "CR"; | |
char_name[14] = "SO"; | |
char_name[15] = "SI"; | |
char_name[16] = "DLE"; | |
char_name[17] = "DC1"; | |
char_name[18] = "DC2"; | |
char_name[19] = "DC3"; | |
char_name[20] = "DC4"; | |
char_name[21] = "NAK"; | |
char_name[22] = "SYN"; | |
char_name[23] = "ETB"; | |
char_name[24] = "CAN"; | |
char_name[25] = "EM"; | |
char_name[26] = "SUB"; | |
char_name[27] = "ESC"; | |
char_name[28] = "FS"; | |
char_name[29] = "GS"; | |
char_name[30] = "RS"; | |
char_name[31] = "US"; | |
printf("DEC\tHEX\tOCT SYMBOL\t\tDEC\tHEX\tOCT SYMBOL\t\tDEC\tHEX\tOCT SYMBOL\t\tDEC\tHEX\tOCT SYMBOL\n"); | |
printf("==============================\t\t==============================\t\t==============================\t\t==============================\t\t\n"); | |
for ( i = 0; i < 32; i++ ) { | |
for ( col = 0; col < 4; col++ ) { | |
code = 32 * col + i; | |
if ( col == 0 ) { | |
printf("%3d\t%2X\t%2o\t%s\t\t", code, code, code, char_name[code]); // Control characters | |
} else | |
printf("%3d\t%2X\t%2o\t%c\t\t", code, code, code, code); // Other characters | |
} | |
printf("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ASCII TABLE
ASCII is the most fundamental character coding map for information technology as well as some engineering technologies. It is also a basic table for other coding method, such as UTF-8.
In general, we represent the codes in DECimal, HEXadecimal and OCTal forms, and name the characters represents "SYMBOL", for not all codes represent characters. Instead, some of them are "Control Characters" which are not printable, they are used to control some data transmission mechanism, or rendering on screen.
Those codes under decimal 32 are control codes. Please refer following list: