18 lines
391 B
Bash
Executable File
18 lines
391 B
Bash
Executable File
#!/bin/sh
|
|
# Expand syntax sugar for SubX string literals.
|
|
# Helpful for converting them into handles to strings.
|
|
|
|
INPUT=$(cat)
|
|
echo " # \"$INPUT\""
|
|
|
|
# print length in bytes
|
|
printf " 0x%x/imm32/size\n" $(echo -n $INPUT |wc -c)
|
|
|
|
# print ascii codes for each character in hex
|
|
echo -n " "
|
|
for c in $(echo "$INPUT" | sed -e 's/./& /g')
|
|
do
|
|
echo -n " 0x$(printf '%x' "'$c")/$c"
|
|
done
|
|
echo
|