Skip to content

Instantly share code, notes, and snippets.

@tobihans
Created September 9, 2022 17:44
Show Gist options
  • Save tobihans/fda0dbcbc08c6932f9dc07c49970cbd8 to your computer and use it in GitHub Desktop.
Save tobihans/fda0dbcbc08c6932f9dc07c49970cbd8 to your computer and use it in GitHub Desktop.
Learning about ASCII and Binary representations
#!/bin/bash
str="$*"
for ((i = 0; i < ${#str}; i++))
do
char="${str:$i:1}"
conv=$(LC_CTYPE=C printf '%d\n' "'$char")
echo -n "$(echo "obase=2; ibase=10; $conv" | bc)"
done
echo -e "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment