pax_global_header00006660000000000000000000000064151417367230014523gustar00rootroot0000000000000052 comment=69c89a6779ce07db271068b95214c56bde736356 ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/000077500000000000000000000000001514173672300177325ustar00rootroot00000000000000ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/.gitignore000066400000000000000000000000751514173672300217240ustar00rootroot00000000000000ascii ascii.1 ascii.html nametable.h splashscreen.h MANIFEST ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/.gitlab-ci.yml000066400000000000000000000007041514173672300223670ustar00rootroot00000000000000build:alpine: image: alpine before_script: - apk update - apk add build-base asciidoctor script: - make CFLAGS="-Werror -Wall -Wextra -pedantic -std=c99" - ./ascii build:debian: image: debian before_script: - apt-get update -qq - apt-get install -qq --no-install-recommends cppcheck gcc libc-dev make asciidoctor script: - make CFLAGS="-Werror -Wall -Wextra -pedantic -std=c99" cppcheck all - ./ascii ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/COPYING000066400000000000000000000024631514173672300207720ustar00rootroot00000000000000 BSD LICENSE Copyright (c) 2015, Eric S. Raymond All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/Makefile000066400000000000000000000044471514173672300214030ustar00rootroot00000000000000# ascii -- interactive ASCII reference # # SPDX-FileCopyrightText: (C) Eric S. Raymond # SPDX-License-Identifier: BSD-2-Clause VERS=$(shell sed -n splashscreen.h \ -e 's/\\/\\\\/g' \ -e 's/"/\\"/g' \ -e 's/.*/"&" "\\n"/' nametable.h: nametable sed nametable.h \ -e '/^#/d' \ -e 's/^[A-Za-z ]*: */ /' \ -e 's/%%/ }, {/' # Note: to suppress the footers with timestamps being generated in HTML, # we use "-a nofooter". # To debug asciidoc problems, you may need to run "xmllint --nonet --noout --valid" # on the intermediate XML that throws an error. .SUFFIXES: .html .adoc .1 .adoc.1: asciidoctor -D. -a nofooter -b manpage $< .adoc.html: asciidoctor -D. -a nofooter -a webfonts! $< clean: rm -f ascii ascii.o splashscreen.h nametable.h rm -f *.rpm *.tar.gz MANIFEST *.1 *.html reflow: @clang-format --style="{IndentWidth: 8, UseTab: ForIndentation}" -i $$(find . -name "*.[ch]") CPPCHECKOPTS = cppcheck: nametable.h splashscreen.h @cppcheck --quiet -DREVISION='"$(VERS)"' $(CPPCHECKOPTS) ascii.c SPLINT_SUPPRESSIONS = -boolops -nullret -initallelements +charintliteral splint: nametable.h splashscreen.h splint +quiet +posixlib $(SPLINT_SUPPRESSIONS) ascii.c spellcheck: spellcheck ascii.adoc install: ascii ascii.1 cp ascii $(DESTDIR)$(PREFIX)/bin/ascii cp ascii.1 $(DESTDIR)$(PREFIX)/share/man/man1 uninstall: rm $(DESTDIR)$(PREFIX)/bin/ascii rm $(DESTDIR)$(PREFIX)/share/man/man1/ascii.1 SOURCES = \ README.adoc COPYING NEWS.adoc control Makefile \ ascii.c ascii.adoc splashscreen nametable version: @echo $(VERS) ascii-$(VERS).tar.gz: $(SOURCES) ascii.1 @ls $(SOURCES) ascii.1 | sed s:^:ascii-$(VERS)/: >MANIFEST @(cd ..; ln -s ascii ascii-$(VERS)) (cd ..; tar -czvf ascii/ascii-$(VERS).tar.gz `cat ascii/MANIFEST`) @(cd ..; rm ascii-$(VERS)) dist: ascii-$(VERS).tar.gz release: ascii-$(VERS).tar.gz ascii.html shipper version=$(VERS) | sh -e -x refresh: ascii.html shipper -N -w version=$(VERS) | sh -e -x ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/NEWS.adoc000066400000000000000000000053051514173672300213410ustar00rootroot00000000000000 ascii project news 3.31: 2026-02-07:: ChatGPT 5.2 patches to hrden code against UB. Manual page is now spellchecked. 3.30: 2024-05-27:: Back out mistaken correction of "Start of Heading." Markup fix. 3.20: 2024-02-16:: Do two user requests for more informative handling of CLI flags. 3.19: 2024-02-07:: Accept 7-bit binary literals, with 0b prefix. Accept names of POSIX character classes. 3.18: 2017-08-01:: Fix a packaging error, include NEWS in the tarball. 3.17: 2017-07-31:: Add -b option to generate a table with binary code-points. 3.16: 2017-07-18:: Add -a option to print in 4-column mode. 0-fill fix and octal code-point literals. 3.15: 2015-04-02:: Gitorious is doomed. Project must move and metadata change accordingly. 3.14: 2013-11-27:: Recognize \0 as ASCII NUL. ascii.cgi deleted: the it relies on is archaic and nonconformant. Markup improvements on the manual page. 3.13: 2013-11-20:: Tweak Makefile to obey $(PREFIX) convention (from MacPorts). 3.12: 2012-11-23:: Cygwin port fix. 3.11: 2011-03-15:: Recognize single decimal or hex digits. Minor bug fixes and additional character names from Debian. 3.10: 2010-10-19:: License change to BSD. Polish code to modern fully-ANSI C. 3.9: 2010-10-13:: Fix some bugs in the name table. 3.8: 2005-03-03:: Well, that was embarrassing. Note to self: *test the correct version next time*. Thanks to Marco Vanoni for the fix patch. 3.7: 2005-03-02:: Fix a comment bug in the nametable. Improve splashscreen generation. 3.6: 2004-01-11:: Fix brown-paper-bag bug in the Space entry. 3.5: 2003-12-28:: Source RPMs no longer require myversion to be defined. 3.4: 2003-12-24:: Fix error in ! entry in nametable file. 3.3: 2003-12-24:: Fix portability bug in Makefile sed script. 3.2: 2003-12-15:: Add knowledge of XML entity names. First released by Eric S. Raymond , v1.0 March 1990 ----- v1.1 November 1990 -- revised `slang' from the 2.2 pronunciation guide v1.2 March 1995 -- Fixed a core-dump bug v1.3 October 1995 -- Fixed a bug that shows up only under ELF. v2.0 December 1995 -- Interpret ISO-style code table escapes. v2.1 August 1997 -- merge in changes by Ioannis Tambouras. v2.2 November 1997 -- merge in more changes by Ioannis Tambouras. v2.3 November 1997 -- incorporated Colin Plumb's splash-screen idea. v2.4 December 1998 -- additions by Brian Ginsbach. v2.5 December 1998 -- -s option by David N. Welton. v2.6 June 1999 -- bug fixes by M.R. van Schouwen. v2.7 October 1999 -- minor packaging and option changes. v3.0 July 2000 -- added HTML/SGML entity names v3.1 July 2002 -- documentation converted to XML ----- ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/README.adoc000066400000000000000000000005541514173672300215230ustar00rootroot00000000000000 = ascii This is a handy little utility that recognizes many different ways of naming an ASCII character (hex, octal, binary, decimal, C escape, ISO character table pair, slang names, and others) and prints out all the equivalents. This code is commonly packaged as "ascii". image:https://repology.org/badge/vertical-allrepos/ascii.svg[Repology package status] ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/ascii-logo.png000066400000000000000000000062751514173672300225000ustar00rootroot00000000000000PNG  IHDR00WbKGD pHYs  tIME $ JIDAThݚole~?]:Ǝ\h&u#$)\%jEA͕R_ E%8r!(JmRrBrqllqg;^։CnG3,?:FGSx<˹9C4Mawh&5M34M4 Zh<xuI@[LP(aEtA?<"j 냦Y|Gu!%8v%ZBK y  a&{% 麎R"SP(y\I5[|_!JJkeY븮[`+߁=9tYA,Y~(zF_dr" r_͕ۅ@8FuL,=j cԵy E h7ʉ/W'(DQ"<\-] `"9U0 9%`LB`XuKguKLP !B*S){ĘjZb1d ()PbW8~[2J֔JG(v7u%sj^W0Xta//l:EIj?ץB]q\A5f(@J 4MlB"(@%B \6 zy<chh|>[Sk2x17gϞٻwF)q0 2 cdd+WA}}=˖-CeYic&X pDQڨY355L0 e mm벩IرcԩSرcK)iY㲷Wi944$;;;KϘ)ܴi<|/#|M$u]w Q%#Cm莍;033y|444C}}=333 022<3=zD"ƍihh`ffAN<8c6|)FFFr C"@a&`yJ*ku]_nݺqΝ;ŋI$psm̮]hii穧 u]P(c=ݻ޿MEzŵl` k`E: q ===+޽>H$BOO۶m#rYfffxGiii ۶e޽XU"X,DU>pD"ā0BшτO`,];wr=PWW|H)dt-"a6͓O>I*ZTJ7뺎eYpYDE_wuVGE_dǎ8pg}_~;wj*:h!(aLNNoU.c~~Bl6K.+Iz(*`-I`O!4=>o>y뭷JMd{{륮벵U[rŊr۶m{uuu;v/lll4M)XL۷˷zKn߾]VWWp8n3rG`~uu8x49s OF4(7o&iO<CCC2<<\(Q*x,L'OtZEbՑˀ "n!k˲,!9sK.a6WT*E,C4OEA*z8q8 y%J!>|?_]pB[$DkkظL5k0aq\.XE4Ŷ˗#ϗWRrt:]J!᪒ {:t%7n۶}>H04mMIJ,Qyd2T%mcYiDzO"咺bM¤R3 MuTk -Z Au) D2FUR k.H+ ,heY+^?]׽˳zUZ^^L=r*yn?tV577:55~dE~Կhr󓓓ZCogKk?҉:HRIENDB`ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/ascii.adoc000066400000000000000000000111261514173672300216530ustar00rootroot00000000000000= ascii(1) = :doctype: manpage //spellcheck: add encodings printables ECMA POSIX stringize //spellcheck: add metacharacters LF == NAME == ascii - report character aliases == SYNOPSIS == *ascii* [-d] [-x] [-o] [-h] [-v] [char-alias] == OPTIONS == Called with no options, +ascii+ behaves like "ascii -h". Options are as follows: -t:: Script-friendly mode, emits only ISO/decimal/hex/octal/binary encodings of the character. -s:: Parse multiple characters. Convenient way of parsing strings. -a:: Print in vertical aspect (4 columns by 16 rows) rather than 16x4. This option combines only with -d -o -x -b and must precede them. -d:: Ascii table in decimal. -x:: Ascii table in hex. -o:: Ascii table in octal. -b:: Ascii table in binary. -h, -?:: Show summary of options and a simple ASCII table. -v:: Show version of program. [[description]] == DESCRIPTION == Characters in the ASCII set can have many aliases, depending on context. A character's possible names include: * Its bit pattern (binary representation). * Its hex, decimal and octal representations. * Its teletype mnemonic and caret-notation form (for control chars). * Its backlash-escape form in C (for some control chars). * Its printed form (for printables). * Its full ISO official name in English. * Its ISO/ECMA code table reference. * Its name as an HTML/SGML entity. * Slang and other names in wide use for it among hackers. This utility accepts command-line strings and tries to interpret them as one of the above. When it finds a value, it prints _all_ of the names of the character. The constructs in the following list can be used to specify character values. If an argument could be interpreted in two or more ways, names for all the different characters it might be are dumped. __character__:: Any character not described by one of the following conventions represents the character itself. ^__character__:: A caret followed by a character. // spellcheck: add abfnrtv \[abfnrtv0]: A backslash followed by certain special characters (abfnrtv). __mnemonic__:: An ASCII teletype mnemonic. // spellcheck: add abcdef __hexadecimal__:: A hexadecimal (hex) sequence consists of one or two case-insensitive hex digit characters (01234567890abcdef). To ensure hex interpretation use one of the prefixes h, 0x, x, or \x. __decimal__:: A decimal sequence consists of one, two or three decimal digit characters (0123456789). To ensure decimal interpretation use one of the prefixes d, 0d, or \d. __octal__:: An octal sequence consists of one, two or three octal digit characters (01234567). To ensure octal interpretation use one of the prefixes 0o, o, or \o. // spellcheck: add bm __bit pattern__:: A bit pattern (binary) sequence consists of one to eight binary digit characters (01). To ensure bit interpretation use one of the prefixes 0bm b, or \b. __ISO/ECMA code__:: An ISO/ECMA code sequence consists of one or two decimal digit characters, a slash, and one or two decimal digit characters. __name__:: An official ASCII or (unofficial) slang name. :__class__: :: A named POSIX character class. The slang names recognized and printed out are from a rather comprehensive list that first appeared on USENET in early 1990 and has been continuously updated since. Mnemonics recognized and printed include the official ASCII set, some official ISO names (where those differ) and a few common-use alternatives (such as NL for LF). HTML/SGML entity names are also printed when applicable. All comparisons are case-insensitive, and dashes are mapped to spaces. Any unrecognized arguments or out of range values are silently ignored. Note that the option will not recognize "long" names, as it cannot differentiate them from other parts of the string. For correct results, be careful to stringize or quote shell metacharacters in arguments (especially backslash). This utility is particularly handy for interpreting cc(1)'s ugly octal "invalid-character" messages, or when coding anything to do with serial communications. As a side effect it serves as a handy base-converter for random 8-bit values. [[author]] == AUTHOR == // spellcheck: off Eric S. Raymond ; November 1990 (home page at added command options and minor enhancements. Brian J. Ginsbach fixed several bugs and expanded the man page. David N. Welton added the option. Matej Vela corrected the ISO names. Dave Capella contributed the idea of listing HTML/SGML entities. // spellcheck: on // end ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/ascii.c000066400000000000000000000313401514173672300211670ustar00rootroot00000000000000/* * ascii.c -- quick crossreference for ASCII character aliases * * Tries to interpret arguments as names or aliases of ascii characters * and dumps out *all* the aliases of each. Accepts literal characters, * standard mnemonics, C-style backslash escapes, caret notation for control * characters, numbers in hex/decimal/octal/binary, English names. * * The slang names used are selected from the 2.2 version of the USENET ascii * pronunciation guide. Some additional ones were merged in from the Jargon * File. * * SPDX-FileCopyrightText: (C) Eric S. Raymond * SPDX-License-Identifier: BSD-2-Clause * * For license terms, see the file COPYING. */ #include #include #include #include #include #include #include #include #define MODE_HELP (1 << 0) #define MODE_VERSION (1 << 1) #define MODE_BTABLE (1 << 2) #define MODE_OTABLE (1 << 3) #define MODE_DTABLE (1 << 4) #define MODE_XTABLE (1 << 5) #define MODE_CHARS (1 << 6) #define MASK_MARKED (1u << 0) #define MASK_CNTRL (1u << 1) #define MASK_SPACE (1u << 2) #define MASK_PUNCT (1u << 3) #define MASK_UPPER (1u << 4) #define MASK_LOWER (1u << 5) #define MASK_DIGIT (1u << 6) #define MASK_XALPHA (1u << 7) #define MASK_WORD (1u << 8) #define MASK_ALPHA (MASK_UPPER | MASK_LOWER) #define MASK_ALNUM (MASK_UPPER | MASK_LOWER | MASK_DIGIT) #define MASK_PRINT (MASK_UPPER | MASK_LOWER | MASK_DIGIT | MASK_PUNCT) #define MASK_GRAPH (MASK_PRINT & ~MASK_SPACE) #define MASK_XDIGIT (MASK_DIGIT | MASK_XALPHA) struct char_class { const char *name; unsigned int mask; }; static char *progname; static bool vertical = false; static bool terse = false; static bool line = false; static const char *cnames[128][16] = {{ #include "nametable.h" }}; static const char splashscreen[] = #include "splashscreen.h" ; /* The character class names are from POSIX. */ const struct char_class char_classes[] = { {":alnum:", MASK_ALNUM}, {":alpha:", MASK_ALPHA}, {":cntrl:", MASK_CNTRL}, {":digit:", MASK_DIGIT}, {":lower:", MASK_LOWER}, {":print:", MASK_PRINT}, {":punct:", MASK_PUNCT}, {":upper:", MASK_UPPER}, {":xdigit:", MASK_XDIGIT}, {":graph:", MASK_GRAPH}, {":word:", MASK_WORD}, {NULL, 0}, }; static unsigned int char_mask_table[256]; /* Case-blind string compare */ static int stricmp(const char *s, const char *t) { while (*s != '\0' && (tolower((unsigned char)*s) == tolower((unsigned char)*t))) { s++, t++; } return (int)(*t - *s); } static unsigned int char_class_mask(const char *name) { const struct char_class *cc; for (cc = char_classes; cc->name; cc++) { if (!strcmp(cc->name, name)) { return cc->mask; } } return 0; } static void init_char_mask_table(void) { unsigned int ch; ch = 0; while (ch < 0x20) { char_mask_table[ch++] = MASK_CNTRL; } char_mask_table[ch++] = MASK_SPACE; while (ch < 0x30) { char_mask_table[ch++] = MASK_PUNCT; } while (ch < 0x3a) { char_mask_table[ch++] = MASK_DIGIT | MASK_WORD; } while (ch < 0x41) { char_mask_table[ch++] = MASK_PUNCT; } while (ch < 0x47) { char_mask_table[ch++] = MASK_UPPER | MASK_XALPHA | MASK_WORD; } while (ch < 0x5b) { char_mask_table[ch++] = MASK_UPPER | MASK_WORD; } while (ch < 0x61) { char_mask_table[ch++] = MASK_PUNCT; } while (ch < 0x67) { char_mask_table[ch++] = MASK_LOWER | MASK_XALPHA | MASK_WORD; } while (ch < 0x7b) { char_mask_table[ch++] = MASK_LOWER | MASK_WORD; } while (ch < 0x7f) { char_mask_table[ch++] = MASK_PUNCT; } char_mask_table[ch] = MASK_CNTRL; /* Delete */ char_mask_table[0x5F] = MASK_WORD; } static void mark_mask(unsigned int mask) { unsigned int ch; for (ch = 0; ch < 128; ch++) { if (char_mask_table[ch] & mask) { char_mask_table[ch] |= MASK_MARKED; } } } static void mark(unsigned int ch) { if (ch != UINT_MAX && ch < 256) { char_mask_table[ch] |= MASK_MARKED; } } /* Binary-to-ASCII conversion */ static const char *btoa(unsigned int val) { static char rep[7 + 1]; char *p = rep + sizeof(rep); *--p = '\0'; do { *--p = (val & 1) ? '1' : '0'; val >>= 1; } while (p > rep); return p; } static unsigned int parse_partial_digits(const char **sp, unsigned int radix) { const char digits[] = "0123456789abcdef"; const char *digitp; const char *s; unsigned int digit, val; s = *sp; if (*s == '\0') { return UINT_MAX; } val = 0; for (; *s != '\0'; s++) { if ((digitp = strchr(digits, tolower((unsigned char)*s))) == NULL) { break; } if ((digit = digitp - digits) >= radix) { break; } val = (val * radix) + digit; if (val >= 256) { val = UINT_MAX; break; } } *sp = s; return val; } static unsigned int parse_digits(const char *s, unsigned int radix) { unsigned int val; val = parse_partial_digits(&s, radix); return (*s == '\0') ? val : UINT_MAX; } static unsigned int parse_prefixed(const char *s) { switch (s[0]) { case 'b': return parse_digits(s + 1, 2); case 'o': return parse_digits(s + 1, 8); case 'd': return parse_digits(s + 1, 10); case 'x': return parse_digits(s + 1, 16); default: return UINT_MAX; } } static unsigned int parse_hi_lo(const char *s) { unsigned int hi, lo; if ((hi = parse_partial_digits(&s, 10)) == UINT_MAX) { return UINT_MAX; } if ((hi >= 16) || (*s != '/')) { return UINT_MAX; } if ((lo = parse_digits(s + 1, 10)) == UINT_MAX) { return UINT_MAX; } if (lo >= 16) { return UINT_MAX; } return 16 * hi + lo; } static void parse_and_mark_number(const char *s) { if (s[0] == '\\') { mark(parse_prefixed(s + 1)); mark(parse_digits(s + 1, 8)); } else { if (s[0] == '0') { mark(parse_prefixed(s + 1)); } else { mark(parse_prefixed(s)); } mark(parse_digits(s, 2)); mark(parse_digits(s, 8)); mark(parse_digits(s, 10)); mark(parse_digits(s, 16)); } } static void parse_and_mark(const char *str) { int ch; unsigned int mask; const char **ptr; size_t len, i; len = strlen(str); /* interpret single characters as themselves */ if (len == 1) { mark((unsigned char)str[0]); } /* process multiple letters */ if (line == 1) { for (i = 0; i < len; i++) { mark((unsigned char)str[i]); } return; } if ((mask = char_class_mask(str))) { mark_mask(mask); return; } /* interpret ^-escapes as control-character notation */ if ((str[0] == '^') && (len == 2)) { if ((str[1] >= '@') && (str[1] <= '_')) { mark(str[1] - '@'); } else if (str[1] == '?') { mark(0x7f); } return; } /* interpret C-style backslash escapes */ if (*str == '\\' && len == 2 && strchr("abfnrtv0", str[1])) { for (ch = 7; ch < 14; ch++) { for (ptr = &cnames[ch][1]; *ptr; ptr++) { if (**ptr == '\\' && strcmp(str, *ptr) == 0) { mark(ch); return; } } } } /* interpret 2 and 3-character ASCII control mnemonics */ if (len == 2 || len == 3) { /* first check for standard mnemonics */ if (stricmp(str, "DEL") == 0) { mark(0x7f); return; } if (stricmp(str, "BL") == 0) { mark(' '); return; } else if (isalpha((unsigned char)str[0])) { for (ch = 0; ch <= 32; ch++) { if (!stricmp(str, cnames[ch][0]) || !strcmp(str, cnames[ch][1])) { mark(ch); return; } } } } /* OK, now try to interpret the string as a numeric */ parse_and_mark_number(str); mark(parse_hi_lo(str)); if ((len > 1) && isalpha((unsigned char)str[0])) { /* try to match long names */ char canbuf[BUFSIZ], *ep; size_t canbuf_len; size_t copy_len; /* map dashes and other junk to spaces */ copy_len = len; if (copy_len >= sizeof(canbuf)) { copy_len = sizeof(canbuf) - 1; } for (i = 0; i < copy_len; i++) { if (str[i] == '-' || isspace((unsigned char)str[i])) { canbuf[i] = ' '; } else { canbuf[i] = str[i]; } } canbuf[copy_len] = '\0'; /* strip `sign' or `Sign' suffix */ canbuf_len = strlen(canbuf); if (canbuf_len >= 4) { ep = canbuf + canbuf_len - 4; if (!strcmp(ep, "sign") || !strcmp(ep, "Sign")) { *ep = '\0'; canbuf_len = strlen(canbuf); } } /* remove any trailing whitespace */ while (canbuf_len > 0 && canbuf[canbuf_len - 1] == ' ') { canbuf[--canbuf_len] = '\0'; } /* look through all long names for a match */ for (ch = 0; ch < 128; ch++) { for (ptr = &cnames[ch][1]; *ptr; ptr++) { if (!stricmp(*ptr, canbuf)) { mark(ch); } } } } } /* List all the names for a given character */ static void print_character(unsigned int ch) { const char **ptr = &cnames[ch][0]; if (terse) { printf("%u/%u %u 0x%02X 0o%o %s\n", ch / 16, ch % 16, ch, ch, ch, btoa(ch)); return; } printf("ASCII %u/%u is decimal %03u, hex %02x, octal %03o, bits %s: ", ch / 16, ch % 16, ch, ch, ch, btoa(ch)); /* display high-half characters */ if (ch & 0x80) { ch &= ~0x80; if (ch == 0x7f) { printf("meta-^?\n"); } else if (isprint((unsigned char)ch)) { printf("meta-%c\n", (char)ch); } else { printf("meta-^%c\n", '@' + (ch & 0x1f)); } return; } if (isprint((unsigned char)ch)) { printf("prints as `%s'\n", *ptr++); } else if (iscntrl((unsigned char)ch) || ch == 0x7f) { if (ch == 0x7f) { printf("called ^?"); } else { printf("called ^%c", '@' + (ch & 0x1f)); } for (; strlen(*ptr) < 4 && isupper((unsigned char)**ptr); ptr++) { printf(", %s", *ptr); } putchar('\n'); } printf("Official name: %s\n", *ptr++); if (*ptr) { const char *commentary = (char *)NULL; if (**ptr == '\\') { printf("C escape: '%s'\n", *ptr); ptr++; } printf("Other names: "); for (; *ptr; ptr++) { if (**ptr == '#') { commentary = *ptr; } else { printf("%s%s ", *ptr, (ptr[1] != NULL && *ptr[1] != '#') ? "," : ""); } } putchar('\n'); if (commentary) { printf("Note: %s\n", commentary + 2); } } putchar('\n'); } static void print_table(unsigned int radix) { unsigned int i, j, len, rows, cols; const char separator[] = " "; const char *tail = separator + 3; const char *space; const char *name; if (vertical) { cols = 4; } else { cols = 8; } rows = 128 / cols; for (i = 0; i < rows; i++) { for (j = 0; j < cols; j++) { name = *cnames[i + (j * rows)]; len = strlen(name); space = tail - (len % 3); switch (radix) { case 10: printf("%5d %1s%1s", i + (j * rows), name, space); break; case 8: printf(" %03o %1s%1s", i + (j * rows), name, space); break; case 16: printf(" %02X %1s%1s", i + (j * rows), name, space); break; case 2: printf(" %s %1s%1s", btoa(i + (j * rows)), name, space); break; } } printf("\n"); } } static void generic_usage(FILE *out, int status) { fprintf(out, "Usage: %s [-adxohv] [-t] [char-alias...]\n", progname); fputs(splashscreen, out); exit(status); } static void usage(void) { generic_usage(stderr, 2); } static unsigned int parse_command_line(int argc, char **argv) { unsigned int mode; int op; mode = 0; progname = argv[0]; while ((op = getopt(argc, argv, "abdhostvx")) != -1) { switch (op) { case 'a': vertical = true; break; case 'b': mode |= MODE_BTABLE; break; case 'd': mode |= MODE_DTABLE; break; case 'h': mode |= MODE_HELP; break; case 'o': mode |= MODE_OTABLE; break; case 's': terse = line = true; break; case 't': terse = true; break; case 'v': mode |= MODE_VERSION; break; case 'x': mode |= MODE_XTABLE; break; case '?': usage(); break; default: usage(); break; } } if (mode & MODE_HELP) { return MODE_HELP; } if (mode & MODE_VERSION) { return MODE_VERSION; } if (mode && (terse || line)) { usage(); } if (mode != 0 && optind < argc) { fprintf(stderr, "ascii: table or help request doesn't mix with arguments.\n"); exit(1); } if (vertical && mode == 0) { fprintf(stderr, "ascii: -a option must be followed by one of -b -d -o -x.\n"); exit(1); } switch (mode) { case 0: break; case MODE_BTABLE: return mode; case MODE_OTABLE: return mode; case MODE_DTABLE: return mode; case MODE_XTABLE: return mode; default: usage(); } if (argc == optind) { return MODE_HELP; } while (optind < argc) { parse_and_mark(argv[optind++]); } return MODE_CHARS; } int main(int argc, char **argv) { unsigned int ch; init_char_mask_table(); switch (parse_command_line(argc, argv)) { case MODE_CHARS: for (ch = 0; ch < 128; ch++) { if (char_mask_table[ch] & MASK_MARKED) { print_character(ch); } } break; case MODE_BTABLE: print_table(2); break; case MODE_OTABLE: print_table(8); break; case MODE_DTABLE: print_table(10); break; case MODE_XTABLE: print_table(16); break; case MODE_VERSION: printf("ascii %s\n", REVISION); break; case MODE_HELP: generic_usage(stdout, 0); break; default: usage(); } return 0; } ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/control000066400000000000000000000020341514173672300213340ustar00rootroot00000000000000# This is not a real Debian control file, though the syntax is compatible. # It's project metadata for the shipper tool # # SPDX-FileCopyrightText: (C) Eric S. Raymond # SPDX-License-Identifier: BSD-2-Clause Package: ascii Description: List ASCII idiomatic names and octal/decimal code-point forms. Provides easy conversion between various byte representations and the American Standard Code for Information Interchange (ASCII) character table. It knows about a wide variety of hex, binary, octal, Teletype mnemonic, ISO/ECMA code point, slang names, XML entity names, and other representations. Given any one on the command line, it will try to display all others. Called with no arguments it displays a handy small ASCII chart. #XBS-Destinations: freshcode Homepage: http://www.catb.org/~esr/ascii XBS-Packaged-As: ascii XBS-HTML-Target: index.html XBS-Repository-URL: https://gitlab.com/esr/ascii XBS-Logo: ascii-logo.png #XBS-Project-Tags: ASCII XBS-VC-Tag-Template: %(version)s XBS-Validate: make spellcheck ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/nametable000066400000000000000000000252131514173672300216100ustar00rootroot00000000000000# Master name table for the ASCII utility. # # The colon-terminated field names are not interpreted, they're for # human eyes. Most of this file gets copied into one big C # initializer. Mnemonics: "NUL", ISO names: "Null", C escape: "\\0", %% Mnemonics: "SOH", ISO names: "Start Of Heading", %% Mnemonics: "STX", ISO names: "Start of Text", %% Mnemonics: "ETX", ISO names: "End of Text", %% Mnemonics: "EOT", ISO names: "End Of Transmission", %% Mnemonics: "ENQ", ISO names: "Enquiry", %% Mnemonics: "ACK", ISO names: "Acknowledge", %% Mnemonics: "BEL", ISO names: "Bell", C escape: "\\a", Synonyms: "Alert", %% Mnemonics: "BS", ISO names: "Backspace", C escape: "\\b", %% Mnemonics: "HT", "TAB", ISO names: "Character Tabulation", "Horizontal Tab", C escape: "\\t", %% Mnemonics: "LF", "NL", ISO name: "Line Feed", "Newline", C escape: "\\n", %% Mnemonics: "VT", ISO names: "Line Tabulation", "Vertical Tab", C escape: "\\v", %% Mnemonics: "FF", ISO names: "Form Feed", C escape: "\\f", %% Mnemonics: "CR", ISO names: "Carriage Return", C escape: "\\r", %% Mnemonics: "SO", "LS1", ISO names: "Shift Out", "Locking Shift 1", %% Mnemonics: "SI", "LS0", ISO names: "Shift In", "Locking Shift 0", %% Mnemonics: "DLE", ISO names: "Data Link Escape", %% Mnemonics: "DC1", ISO names: "Device Control 1", %% Mnemonics: "DC2", ISO names: "Device Control 2", %% Mnemonics: "DC3", ISO names: "Device Control 3", %% Mnemonics: "DC4", ISO names: "Device Control 4", %% Mnemonics: "NAK", ISO names: "Negative Acknowledge", %% Mnemonics: "SYN", ISO names: "Synchronous Idle", %% Mnemonics: "ETB", ISO names: "End of Transmission Block", %% Mnemonics: "CAN", ISO names: "Cancel", %% Mnemonics: "EM", ISO names: "End of Medium", %% Mnemonics: "SUB", ISO names: "Substitute", %% Mnemonics: "ESC", ISO names: "Escape", %% Mnemonics: "FS", ISO names: "File Separator", %% Mnemonics: "GS", ISO names: "Group Separator", %% Mnemonics: "RS", ISO names: "Record Separator", %% Mnemonics: "US", ISO names: "Unit Separator", %% Mnemonics: " ", "SP", ISO names: "Space", "Blank", %% Mnemonics: "!", ISO names: "Exclamation Mark", Synonyms: "Bang", "Excl", "Wow", "Factorial", "Shriek", "Pling", "Smash", "Cuss", %% Mnemonics: "\"", ISO names: "Quotation Mark", Synonyms: "Double Quote", "Quote", "String Quote", "Dirk", "Literal Mark", "Double Glitch", XML name: """, Comment: "# See ' and ` for matching names.", %% Mnemonics: "#", ISO names: "Number Sign", Synonyms: "Pound", "Number", "Sharp", "Crunch", "Mesh", "Hex", "Hash", "Flash", "Grid", "Octothorpe", %% Mnemonics: "$", ISO names: "Currency Sign", Synonyms: "Dollar", "Buck", "Cash", "Ding", %% Mnemonics: "%", ISO names: "Percent Sign", Synonyms: "Mod", "Modulo", %% Mnemonics: "&", ISO names: "Ampersand", Synonyms: "Amper", "And", XML name: "&", %% Mnemonics: "'", ISO names: "Apostrophe", Synonyms: "Single Quote", "Close Quote", "Prime", "Tick", "Pop", "Spark", "Glitch", XML name: "'", Comment: "# See ` and \" for matching names.", %% Mnemonics: "(", ISO names: "Left Parenthesis", Synonyms: "Open", "Open Paren", "Left Paren", "Wax", "Sad", Comment: "# See ) for matching names.", %% Mnemonics: ")", ISO names: "Right Parenthesis", Synonyms: "Close", "Close Paren", "Right Paren", "Wane", "Happy", Comment: "# See ( for matching names.", %% Mnemonics: "*", ISO names: "Asterisk", Synonyms: "Star", "Splat", "Aster", "Times", "Gear", "Dingle", "Bug", "Twinkle", "Glob" , %% Mnemonics: "+", ISO names: "Plus Sign", Synonyms: "Add", "Cross", %% Mnemonics: ",", ISO names: "Comma", Synonyms: "Tail", %% Mnemonics: "-", ISO names: "Hyphen", Synonyms: "Dash", "Minus", "Worm", %% Mnemonics: ".", ISO names: "Full Stop", Synonyms: "Dot", "Decimal Point", "Radix Point", "Point", "Period", "Spot", %% Mnemonics: "/", ISO names: "Solidus", Synonyms: "Slash", "Stroke", "Slant", "Diagonal", "Virgule", "Over", "Slat", Comment: "# See \\ for matching names.", %% Mnemonics: "0", ISO names: "Digit Zero", %% Mnemonics: "1", ISO names: "Digit One", %% Mnemonics: "2", ISO names: "Digit Two", %% Mnemonics: "3", ISO names: "Digit Three", %% Mnemonics: "4", ISO names: "Digit Four", %% Mnemonics: "5", ISO names: "Digit Five", %% Mnemonics: "6", ISO names: "Digit Six", %% Mnemonics: "7", ISO names: "Digit Seven", %% Mnemonics: "8", ISO names: "Digit Eight", %% Mnemonics: "9", ISO names: "Digit Nine", %% Mnemonics: ":", ISO names: "Colon", Synonyms: "Double-Dot", %% Mnemonics: ";", ISO names: "Semicolon", Synonyms: "Semi", "Go-on", %% Mnemonics: "<", ISO names: "Less-than Sign", Synonyms: "Left Angle Bracket", "Read From", "In", "From", "Comesfrom", "Left Funnel", "Left Broket", "Crunch", "Suck", XML name: "<", Comment: "# See > for matching names.", %% Mnemonics: "=", ISO names: "Equals Sign", Synonyms: "Quadrathorp", "Gets", "Becomes", "Half-Mesh", %% Mnemonics: ">", ISO names: "Greater-than sign", Synonyms: "Right Angle Bracket", "Write To", "Into", "Toward", "Out", "To", "Gozinta", "Right Funnel", "Right Broket", "Zap", "Blow", XML name: ">", Comments: "# See < for matching names.", %% Mnemonics: "?", ISO names: "Question Mark", Comments: "Whatmark", "What", "Ques", %% Mnemonics: "@", ISO names: "Commercial At", Synonyms: "At", "Each", "Vortex", "Whorl", "Whirlpool", "Cyclone", "Snail", "Rose", %% Mnemonics: "A", ISO names: "Majuscule A", "Capital A", "Uppercase A", %% Mnemonics: "B", ISO names: "Majuscule B", "Capital B", "Uppercase B", %% Mnemonics: "C", ISO names: "Majuscule C", "Capital C", "Uppercase C", %% Mnemonics: "D", ISO names: "Majuscule D", "Capital D", "Uppercase D", %% Mnemonics: "E", ISO names: "Majuscule E", "Capital E", "Uppercase E", %% Mnemonics: "F", ISO names: "Majuscule F", "Capital F", "Uppercase F", %% Mnemonics: "G", ISO names: "Majuscule G", "Capital G", "Uppercase G", %% Mnemonics: "H", ISO names: "Majuscule H", "Capital H", "Uppercase H", %% Mnemonics: "I", ISO names: "Majuscule I", "Capital I", "Uppercase I", %% Mnemonics: "J", ISO names: "Majuscule J", "Capital J", "Uppercase J", %% Mnemonics: "K", ISO names: "Majuscule K", "Capital K", "Uppercase K", %% Mnemonics: "L", ISO names: "Majuscule L", "Capital L", "Uppercase L", %% Mnemonics: "M", ISO names: "Majuscule M", "Capital M", "Uppercase M", %% Mnemonics: "N", ISO names: "Majuscule N", "Capital N", "Uppercase N", %% Mnemonics: "O", ISO names: "Majuscule O", "Capital O", "Uppercase O", %% Mnemonics: "P", ISO names: "Majuscule P", "Capital P", "Uppercase P", %% Mnemonics: "Q", ISO names: "Majuscule Q", "Capital Q", "Uppercase Q", %% Mnemonics: "R", ISO names: "Majuscule R", "Capital R", "Uppercase R", %% Mnemonics: "S", ISO names: "Majuscule S", "Capital S", "Uppercase S", %% Mnemonics: "T", ISO names: "Majuscule T", "Capital T", "Uppercase T", %% Mnemonics: "U", ISO names: "Majuscule U", "Capital U", "Uppercase U", %% Mnemonics: "V", ISO names: "Majuscule V", "Capital V", "Uppercase V", %% Mnemonics: "W", ISO names: "Majuscule W", "Capital W", "Uppercase W", %% Mnemonics: "X", ISO names: "Majuscule X", "Capital X", "Uppercase X", %% Mnemonics: "Y", ISO names: "Majuscule Y", "Capital Y", "Uppercase Y", %% Mnemonics: "Z", ISO names: "Majuscule Z", "Capital Z", "Uppercase Z", %% Mnemonics: "[", ISO names: "Left Square Bracket", Synonyms: "Bracket", "Bra", "Square", Comments: "# See ] for matching names.", %% Mnemonics: "\\", ISO names: "Reversed Solidus", Synonyms: "Backslash", "Bash", "Backslant", "Backwhack", "Backslat", "Literal", "Escape", Comments: "# See / for matching names.", %% Mnemonics: "]", ISO names: "Right Square Bracket", Synonyms: "Unbracket", "Ket", "Unsquare", Comments: "# See [ for matching names.", %% Mnemonics: "^", ISO names: "Circumflex Accent", Synonyms: "Circumflex", "Caret", "Uparrow", "Hat", "Control", "Boink", "Chevron", "Hiccup", "Sharkfin", "Fang", %% Mnemonics: "_", ISO names: "Low Line", Synonyms: "Underscore", "Underline", "Underbar", "Under", "Score", "Backarrow", "Flatworm", Comments: "# Backarrow refers to this character's graphic in 1963 ASCII.", %% Mnemonics: "`", ISO names: "Grave Accent", Synonyms: "Grave", "Backquote", "Left Quote", "Open Quote", "Backprime", "Unapostrophe", "Backspark", "Birk", "Blugle", "Back Tick", "Push", Comments: "# See ' and \" for matching names.", %% Mnemonics: "a", ISO names: "Miniscule a", "Small a", "Lowercase a", %% Mnemonics: "b", ISO names: "Miniscule b", "Small b", "Lowercase b", %% Mnemonics: "c", ISO names: "Miniscule c", "Small c", "Lowercase c", %% Mnemonics: "d", ISO names: "Miniscule d", "Small d", "Lowercase d", %% Mnemonics: "e", ISO names: "Miniscule e", "Small e", "Lowercase e", %% Mnemonics: "f", ISO names: "Miniscule f", "Small f", "Lowercase f", %% Mnemonics: "g", ISO names: "Miniscule g", "Small g", "Lowercase g", %% Mnemonics: "h", ISO names: "Miniscule h", "Small h", "Lowercase h", %% Mnemonics: "i", ISO names: "Miniscule i", "Small i", "Lowercase i", %% Mnemonics: "j", ISO names: "Miniscule j", "Small j", "Lowercase j", %% Mnemonics: "k", ISO names: "Miniscule k", "Small k", "Lowercase k", %% Mnemonics: "l", ISO names: "Miniscule l", "Small l", "Lowercase l", %% Mnemonics: "m", ISO names: "Miniscule m", "Small m", "Lowercase m", %% Mnemonics: "n", ISO names: "Miniscule n", "Small n", "Lowercase n", %% Mnemonics: "o", ISO names: "Miniscule o", "Small o", "Lowercase o", %% Mnemonics: "p", ISO names: "Miniscule p", "Small p", "Lowercase p", %% Mnemonics: "q", ISO names: "Miniscule q", "Small q", "Lowercase q", %% Mnemonics: "r", ISO names: "Miniscule r", "Small r", "Lowercase r", %% Mnemonics: "s", ISO names: "Miniscule s", "Small s", "Lowercase s", %% Mnemonics: "t", ISO names: "Miniscule t", "Small t", "Lowercase t", %% Mnemonics: "u", ISO names: "Miniscule u", "Small u", "Lowercase u", %% Mnemonics: "v", ISO names: "Miniscule v", "Small v", "Lowercase v", %% Mnemonics: "w", ISO names: "Miniscule w", "Small w", "Lowercase w", %% Mnemonics: "x", ISO names: "Miniscule x", "Small x", "Lowercase x", %% Mnemonics: "y", ISO names: "Miniscule y", "Small y", "Lowercase y", %% Mnemonics: "z", ISO names: "Miniscule z", "Small z", "Lowercase z", %% Mnemonics: "{", ISO names: "Left Curly Bracket", Synonyms: "Left Brace", "Brace", "Open Brace", "Curly", "Leftit", "Embrace", Comments: "# See } for matching names.", %% Mnemonics: "|", ISO names: "Vertical Line", Synonyms: "Pipe", "Bar", "Or", "V-Bar", "Spike", "Gozinta", "Thru", %% Mnemonics: "}", ISO names: "Right Curly Bracket", Synonyms: "Right Brace", "Unbrace", "Close Brace", "Uncurly", "Rytit", "Bracelet", Comments: "# See { for matching names.", %% Mnemonics: "~", ISO names: "Overline", Synonyms: "Tilde", "Swung Dash", "Squiggle", "Approx", "Wiggle", "Twiddle", "Enyay", %% Mnemonics: "DEL", ISO names: "Delete", ascii-3.31-69c89a6779ce07db271068b95214c56bde736356/splashscreen000066400000000000000000000031601514173672300223470ustar00rootroot00000000000000 -t = one-line output -a = vertical format -d = decimal table -o = octal table -x = hex table -b binary table -h = this help screen -v = version information Prints all aliases of an ASCII character. Args may be chars, C \-escapes, English names, ^-escapes, ASCII mnemonics, or numerics in decimal/octal/hex. Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex 0 00 NUL 16 10 DLE 32 20 48 30 0 64 40 @ 80 50 P 96 60 ` 112 70 p 1 01 SOH 17 11 DC1 33 21 ! 49 31 1 65 41 A 81 51 Q 97 61 a 113 71 q 2 02 STX 18 12 DC2 34 22 " 50 32 2 66 42 B 82 52 R 98 62 b 114 72 r 3 03 ETX 19 13 DC3 35 23 # 51 33 3 67 43 C 83 53 S 99 63 c 115 73 s 4 04 EOT 20 14 DC4 36 24 $ 52 34 4 68 44 D 84 54 T 100 64 d 116 74 t 5 05 ENQ 21 15 NAK 37 25 % 53 35 5 69 45 E 85 55 U 101 65 e 117 75 u 6 06 ACK 22 16 SYN 38 26 & 54 36 6 70 46 F 86 56 V 102 66 f 118 76 v 7 07 BEL 23 17 ETB 39 27 ' 55 37 7 71 47 G 87 57 W 103 67 g 119 77 w 8 08 BS 24 18 CAN 40 28 ( 56 38 8 72 48 H 88 58 X 104 68 h 120 78 x 9 09 HT 25 19 EM 41 29 ) 57 39 9 73 49 I 89 59 Y 105 69 i 121 79 y 10 0A LF 26 1A SUB 42 2A * 58 3A : 74 4A J 90 5A Z 106 6A j 122 7A z 11 0B VT 27 1B ESC 43 2B + 59 3B ; 75 4B K 91 5B [ 107 6B k 123 7B { 12 0C FF 28 1C FS 44 2C , 60 3C < 76 4C L 92 5C \ 108 6C l 124 7C | 13 0D CR 29 1D GS 45 2D - 61 3D = 77 4D M 93 5D ] 109 6D m 125 7D } 14 0E SO 30 1E RS 46 2E . 62 3E > 78 4E N 94 5E ^ 110 6E n 126 7E ~ 15 0F SI 31 1F US 47 2F / 63 3F ? 79 4F O 95 5F _ 111 6F o 127 7F DEL