Is there a standard shell command to convert a binary sequence containing a mix of ASCII and non-ASCII characters into an all-ASCII sequence, that keeps all printable non-whitespace ASCII characters intact and changes all the others (non-ASCII + whitespace) characters into x-notation symbols understandable by echo -e
?
For example, let's say I have a string ʃBC\n
- note, that the first symbol is a Latin letter "esh" and the last symbol is a newline, second and third are ASCII symbols B
and C
.
In UTF-8 this string encodes to ca 83 42 43 0a
bytes. The command I'm looking for needs to change original string to \xca\x83BC\x0a
- so that I can print the original string via echo -ne "\xca\x83BC\x0a"
, assuming UTF-8 encoding is used.