aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-02-07 16:27:37 -0600
committerRob Landley <rob@landley.net>2017-02-07 16:27:37 -0600
commit2fdeb3aaf292f64c69ecb63c98b0a6caedc60530 (patch)
treec7b18d63089c1a9151a76df1cfc8d30524f67667 /toys
parentaf857c67a89a8f73e81255b56ea12936b4c55b67 (diff)
downloadtoybox-2fdeb3aaf292f64c69ecb63c98b0a6caedc60530.tar.gz
Add ascii: display ascii table.
Diffstat (limited to 'toys')
-rw-r--r--toys/other/ascii.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/toys/other/ascii.c b/toys/other/ascii.c
new file mode 100644
index 00000000..4d33ae61
--- /dev/null
+++ b/toys/other/ascii.c
@@ -0,0 +1,39 @@
+/* ascii.c - display ascii table
+ *
+ * Copyright 2017 Rob Landley <rob@landley.net>
+ *
+ * Technically 7-bit ASCII is ANSI X3.4-1986, a standard available as
+ * INCITS 4-1986[R2012] on ansi.org, but they charge for it.
+
+USE_ASCII(NEWTOY(ascii, 0, TOYFLAG_USR|TOYFLAG_BIN))
+
+config ASCII
+ bool "ascii"
+ default n
+ help
+ usage: ascii
+
+ Display ascii character set.
+*/
+
+#include "toys.h"
+
+void ascii_main(void)
+{
+ char *low="NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4"
+ "NAKSYNETBCANEM SUBESCFS GS RS US ";
+ int x, y;
+
+ for (x = 0; x<8; x++) printf("Dec Hex%*c", 2+2*(x<2)+(x>4), ' ');
+ xputc('\n');
+ for (y=0; y<15; y++) {
+ for (x=0; x<8; x++) {
+ int i = x*16+y;
+
+ printf("% 3d %02X ", i, i);
+ if (i<32) printf("%.3s ", low+3*i);
+ else printf("%*c ", 2*(i>95 && i<100), i);
+ }
+ xputc('\n');
+ }
+}