AceCommon
1.5.2
Arduino library for low-level common functions and features with no external dependencies
|
Quick and simple implementation of the backslash-x encoding \xHH
, where HH
are 2 hexadecimal digits. This is intended to be used to view ASCII strings with embedded control characters as printable characters, without the danger of messing up the character terminal due to the control characters.
Quick summary of the encoding:
\xHH
, where HH
is the 2-digit hexadecimal ASCII code.\
itself is converted into two backslashes \\
instead of \x5A
for readability.Two functions are provided:
s
and target t
are both always NUL-terminated C-strings.tcap
is the capacity of t
, including the NUL termination character.written
parameter is a pointer to an output parameter to indicatewritten
parameter is the number of bytes written to t
. A nullptr
can be passed in if you don't care about this. It is intended to be helpful for chaining multiple calls into a single target t
string.These functions do not use the String
class to avoid heap fragmentation.
See tests/BackslashXEncodingTest for examples of error handling.