@@ -84,8 +84,9 @@ arg_duo, arg_hex, arg_b32, arg_b64, switch_prefix, param_prefix, switch_lowercase, + switch_7bit, arg_ebcdic, }; @@ -127,8 +128,9 @@ {arg_hex, "b32"}, {arg_hex, "base32"}, /* not padded! */ {switch_prefix, "-p"}, {switch_prefix, "--prefix"}, {switch_lowercase, "-l"}, {switch_lowercase, "--lowercase"}, + {switch_7bit, "-7"}, {switch_7bit, "--7bit"}, {param_prefix, "-m"}, {param_prefix, "--manual-prefix"}, {arg_ebcdic, "ebcdic"}, }; @@ -141,8 +143,11 @@ iaia_e_domain = bad_domain, iaia_e_base = bad_base, iaia_e_overflow = bad_overflow, }; +bool ascii_7bit = false; +#define _IAIA_EXP_ASCFORM ascii_7bit +#define _IAIA_EXTERNAL_TYPES #include "clib/iaia.c" bad run(const int argc, const char** argv) { # ifndef _POSIX_IO @@ -164,9 +169,9 @@ bool lowercase = false; for (const char** arg = argv + 1; *arg != null; ++arg) { uint8_t tblval; - if (*arg[0] == '%') { ++ *arg; goto number; } else + if (*arg[0] == '`') { ++ *arg; goto number; } else if (!raw && (tblget(sz(argtbl),argtbl, *arg, &tblval) == ok)) { enum argument symbol = (enum argument) tblval; switch (symbol) { case arg_to: { @@ -200,8 +205,9 @@ /* specify an automatic output prefix */ case switch_prefix: { prefix = true; pfxstr = null; } break; case switch_lowercase: { lowercase = true; } break; + case switch_7bit: { ascii_7bit = true; } break; default: { /* assume base shorthand */ base[curset] = bases[symbol]; @@ -289,13 +295,18 @@ p("binary literal: "lit("0b") box("01") plus), p("ternary literal: "lit("0t") box("012") plus), p("hex literal: "lit("0x") box("0-9A-Fa-f") plus), p("ascii literal: "lit("@") "\x1b[94m.+\x1b[m"), - p("interpret any string (e.g. a keyword) as integer: " lit("%") box("0-9A-Za-z") plus), + p("interpret any string (e.g. a keyword) as integer: " lit("`") box("0-9A-Za-z") plus), }, opts[] = { p("-p --prefix : print known prefix codes on output strings"), p("-m --manual-prefix: specify a manual prefix to print before each number"), p("-l --lowercase : prefer lowercase for case-insensitive bases"), + p("-7 --7bit : encode ascii in 7-bit space instead of keeping the"), + p(" eighth empty bit. if this option is used, ascii"), + p(" strings will be maximally compact, but will not match"), + p(" the way they are stored in computer memory!"), + /* p("-u --utf : allow non-ascii input"), */ }; # undef p # undef OR # undef plus