Last active
January 5, 2023 01:28
-
-
Save hitalos/17d7fb342cddf78c096d732aa37d0f91 to your computer and use it in GitHub Desktop.
ASCII table
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
package main | |
import ( | |
"fmt" | |
) | |
const ( | |
numCols = 4 | |
height = 32 | |
width = 20 | |
) | |
var values = map[int]string{ | |
0: "NULL", | |
1: "SOH", // start if heading | |
2: "STX", // start of text | |
3: "ETX", // end of text | |
4: "EOT", // end of transmission | |
5: "ENQ", // enquiry | |
6: "ACK", // acknowledge | |
7: "BEL", // bell | |
8: "BS", // backspace | |
9: "TAB", // horizontal tab | |
10: "LF", // line feed | |
11: "VT", // vertical tab | |
12: "FF", // form feed | |
13: "CR", // carriage return | |
14: "SO", // shift out | |
15: "SI", // shift in | |
16: "DLE", // data link escape | |
17: "DC1", // device control 1 | |
18: "DC2", // device control 2 | |
19: "DC3", // device control 3 | |
20: "DC4", // device control 4 | |
21: "NAK", // negative acknowledge | |
22: "SYN", // synchronous idle | |
23: "ETB", // end of transmission block | |
24: "CAN", // cancel | |
25: "EM", // end of medium | |
26: "SUB", // substitute | |
27: "ESC", // escape | |
28: "FS", // file separator | |
29: "GS", // group separator | |
30: "RS", // record separator | |
31: "US", // unit separator | |
32: "Space", | |
127: "DEL", | |
} | |
func main() { | |
var goToFirstLine bool | |
for i := 0; i < numCols; i++ { | |
printCol(i*height, i*width, goToFirstLine) | |
goToFirstLine = true | |
} | |
} | |
func printCol(startCode, startCol int, firstLine bool) { | |
if firstLine { | |
fmt.Printf("\x1b[%dA", height) | |
} | |
for i := 0; i < height; i++ { | |
fmt.Printf("\x1b[%dC", startCol) | |
fmt.Printf("%3[1]d - %3[1]X - %[2]s\n", i+startCode, translate(i+startCode)) | |
} | |
} | |
func translate(n int) string { | |
if _, ok := values[n]; ok { | |
return values[n] | |
} | |
return fmt.Sprintf("%c", n) | |
} |
Author
hitalos
commented
Dec 1, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment