Releases: sdball/printable-ascii
printable-ascii v4.0.0
Breaking Changes
Numeric representations of ASCII characters are now padded.
previously
CHARACTER BINARY OCTAL DECIMAL HEXADECIMAL
100000 40 32 20
! 100001 41 33 21
" 100010 42 34 22
currently
CHARACTER BINARY OCTAL DECIMAL HEXADECIMAL
0100000 040 032 20
! 0100001 041 033 21
" 0100010 042 034 22
New Features
ASCII Control Characters
ASCII control characters can now be included in both informational output and STDIN filtering.
--control
include the control characters--newline
include the newline character AND preserve newlines when filtering STDIN
When filtering STDIN the --control
option will include ASCII control characters in the output BUT the characters will be translated to printable ASCII. e.g. <NUL>
instead the literal NUL character.
If the --newline
option is given then newline will be specially preserved in the filtered output. Otherwise newline will be output as <EOL>
When including control characters in the informational output they will be represented by their abbreviations e.g. "NUL" instead of the literal NUL character.
$ printable-ascii --control -bd --name
CHARACTER BINARY DECIMAL NAME
NUL 0000000 000 NULL
SOH 0000001 001 START OF HEADING
STX 0000010 002 START OF TEXT
ETX 0000011 003 END OF TEXT
EOT 0000100 004 END OF TRANSMISSION
ENQ 0000101 005 ENQUIRY
ACK 0000110 006 ACKNOWLEDGE
BEL 0000111 007 BELL
BS 0001000 008 BACKSPACE
TAB 0001001 009 CHARACTER TABULATION
EOL 0001010 010 LINE FEED (LF)
VT 0001011 011 LINE TABULATION
FF 0001100 012 FORM FEED (FF)
CR 0001101 013 CARRIAGE RETURN (CR)
SO 0001110 014 SHIFT OUT
SI 0001111 015 SHIFT IN
DLE 0010000 016 DATA LINK ESCAPE
DC1 0010001 017 DEVICE CONTROL ONE
DC2 0010010 018 DEVICE CONTROL TWO
DC3 0010011 019 DEVICE CONTROL THREE
DC4 0010100 020 DEVICE CONTROL FOUR
NAK 0010101 021 NEGATIVE ACKNOWLEDGE
SYN 0010110 022 SYNCHRONOUS IDLE
ETB 0010111 023 END OF TRANSMISSION BLOCK
CAN 0011000 024 CANCEL
EOM 0011001 025 END OF MEDIUM
SUB 0011010 026 SUBSTITUTE
ESC 0011011 027 ESCAPE
FS 0011100 028 INFORMATION SEPARATOR FOUR
GS 0011101 029 INFORMATION SEPARATOR THREE
RS 0011110 030 INFORMATION SEPARATOR TWO
US 0011111 031 INFORMATION SEPARATOR ONE
DEL 1111111 127 DELETE
printable-ascii v3.1.2
Bugfixes
- JSON output is no longer malformed in cases with a lot of output. There was some issue with how I was trying to nicely detect if STDIN had any contents or not. I've reverted back to my initial simple
$stdin.tty?
approach which unfortunately means that running the script from docker will require the-t
flag.
docker run -t sdball/printable-ascii
printable-ascii v3.1.1
Bugfixes
The first character of filtered STDIN was not being filtered down to the specified ranges of printable ASCII.
The buggy behavior
$ echo "{1234}" | printable-ascii --octal-digits
{1234
Now fixed!
$ echo "{1234}" | printable-ascii --octal-digits
1234
printable-ascii v3.1.0
v3.1.0
New Features
Filtering STDIN!
Now you can pipe to printable-ascii
and it will output any bytes from STDIN that are printable ASCII characters. You can even limit the characters you want to allow with --range
or named ranges declarations.
When filtering STDIN any declared formatting and representations options are ignored.
$ cat Dockerfile | ./bin/printable-ascii --uppercase
FROMWORKDIRCOPYENTRYPOINT
$ echo "hello123" | ./bin/printable-ascii --numeric
123
$ echo "hello123" | ./bin/printable-ascii --lowercase
hello
You can filter anything! Any printable ASCII characters will be output. It can be a fun way to examine binary files.
$ cat printable-ascii.png | ./bin/printable-ascii | head -c 45; echo
PNGIHDRcH IDATxY\<`0$f~O_ xC IHfOZX}N*uT<;^{<
$ cat printable-ascii.png | ./bin/printable-ascii --alphabetic --numeric | head -c 45; echo
PNGIHDRcHIDATxY0fOxCIHfOZXNuT9e2Pe2Pkke2Pe2PG
$ cat [email protected] | ./bin/printable-ascii | head -c 45; echo
PNGIHDRwv IDATxS?ssgCeJR*MJ_L)dh052D45""2+u3Z%
See the "PNG" at the start there? That's actually the printable ASCII part of the header declaring the file is a PNG!
It's like a slower strings
command that has more filtering options, woo!
Filtering STDIN while using docker run
requires passing the -i
flag to docker run to allow STDIN to go into the container from the host.
$ echo "xyzzy ⌥pl⌃ugh" | docker run -i sdball/printable-ascii
xyzzy plugh
Passing options to the script works as it should
$ echo "xyzzy ⌥pl⌃ugh" | docker run -i sdball/printable-ascii --range x-z
xyzzy
printable-ascii v3.0.2
Fixes
Fix normal --range
declarations that were broken by 3.0.1 e.g. --range A-C
printable-ascii v3.0.1
Fixes
--range
options starting or ending with a literal "-" are now properly handled
$ bin/printable-ascii --range ---
-
$ bin/printable-ascii --range +--
+
,
-
$ bin/printable-ascii --range --3
-
.
/
0
1
2
3
printable-ascii v3.0.0
Breaking Changes
--compact
console output now prints a newline after output--json
output now wraps the results in an array to make the output consistent with and without the--times
option- now
[[{"character":"6"},{"character":"9"}]]
- previous
[{"character":"6"},{"character":"1"}]
- now
--compact --json
output is now an array of joined strings instead of an array of individual characters- now
["A7"]
- previously
["A", "7"]
- now
New Features
--times NUMBER
The --times NUMBER
option repeats the requested pattern NUMBER
of times.
For example: --hex-color --times 5
will output 5 random hex colors.
$ printable-ascii --hex-color --times 5
6B47F6
9365B0
55676F
A7DB92
1EC851
The repeating data does the sensible thing for each type of output.
Console
$ printable-ascii --hex-digits --random 2
C
7
$ printable-ascii --hex-digits --random 2 --times 3
B
4
0
8
5
5
Compact Console
$ printable-ascii --hex-digits --random 2 --compact
9A
$ printable-ascii --hex-digits --random 2 --times 3 --compact
A3
82
20
JSON
$ printable-ascii --hex-digits --random 2 --json | jq -c '.[]'
[{"character":"C"},{"character":"B"}]
$ printable-ascii --hex-digits --random 2 --json --times 3 | jq -c '.[]'
[{"character":"A"},{"character":"0"}]
[{"character":"2"},{"character":"D"}]
[{"character":"1"},{"character":"4"}]
Compact JSON
$ printable-ascii --hex-digits --random 2 --json --compact | jq -c '.[]'
"A0"
$ printable-ascii --hex-digits --random 2 --json --compact --times 3 | jq -c '.[]'
"B0"
"D9"
"BC"
printable-ascii v2.5.0
New Features
--hex-color
option
The --hex-color
option outputs a random hex color code.
Shorthand for
--hex-digits --random 6 --compact
printable-ascii v2.4.0
New Features
--compact
The --compact
option only prints the ASCII characters and omits newlines. When combined with --json
it puts a JSON array with only the characters.
$ printable-ascii --binary-digits
0
1
$ printable-ascii --binary-digits --compact
01%
$ printable-ascii --binary-digits --json
[{"character":"0"},{"character":"1"}]
$ printable-ascii --binary-digits --json --compact
["0","1"]
This can be used for all sorts of fun output. Like random HEX colors
$ printable-ascii --hex-digits --random 6 --compact
FADD5A%
$ printable-ascii --hex-digits --random 6 --compact
341349%
$ printable-ascii --hex-digits --random 6 --compact
B033A5%
printable-ascii v2.3.0
New Features
- Add
--name
as an alias to--character-name