1/* ascii.c - display ascii table 2 * 3 * Copyright 2017 Rob Landley <rob@landley.net> 4 * 5 * Technically 7-bit ASCII is ANSI X3.4-1986, a standard available as 6 * INCITS 4-1986[R2012] on ansi.org, but they charge for it. 7 * 8 * unicode.c - convert between Unicode and UTF-8 9 * 10 * Copyright 2020 The Android Open Source Project. 11 * 12 * Loosely based on the Plan9/Inferno unicode(1). 13 14USE_ASCII(NEWTOY(ascii, 0, TOYFLAG_USR|TOYFLAG_BIN)) 15 16config ASCII 17 bool "ascii" 18 default y 19 help 20 usage: ascii 21 22 Display ascii character set. 23*/ 24 25#include "toys.h" 26 27void ascii_main(void) 28{ 29 char *low="NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4" 30 "NAKSYNETBCANEM SUBESCFS GS RS US "; 31 int x, y; 32 33 for (x = 0; x<8; x++) printf("Dec Hex%*c", 2+2*(x<2)+(x>4), ' '); 34 xputc('\n'); 35 for (y=0; y<=15; y++) { 36 for (x=0; x<8; x++) { 37 int i = x*16+y; 38 39 if (i>95 && i<100) putchar(' '); 40 printf("% 3d %02X ", i, i); 41 if (i<32 || i==127) printf("%.3s ", (i==127) ? "DEL" : low+3*i); 42 else printf("%c ", i); 43 } 44 xputc('\n'); 45 } 46} 47