I imagine that many situations where you might want to embed assets into a binary involve embedded work. With embedded work you often want to be able to cross-compile. Requiring that the koio tool be built first on the host architecture (as opposed to the target architecture) gets messy, especially if you can't or don't want to depend on having it preinstalled.<p>The koio utility might better written in POSIX shell.<p>FWIW, here's a simple POSIX shell-compatible routine that will convert an 8-bit stream into a quoted C string<p><pre><code> cstring() {
# use od to translate each byte to hexadecimal, sed to format as
# proper C string
od -An -tx1 -v | sed -ne '/./p' | sed -e '
# prefix \x to each hexadecimal pair and remove trailing space
s/\([0-9a-fA-F][0-9a-fA-F]\)[[:space:]]*/\\x\1/g;
# quote escaped bytes
s/^[[:space:]]*/"/;
s/$/"/;
# escape newline for all but the last line
$!s/$/ \\/;
'
}</code></pre>