Created
September 9, 2022 17:44
-
-
Save tobihans/fda0dbcbc08c6932f9dc07c49970cbd8 to your computer and use it in GitHub Desktop.
Learning about ASCII and Binary representations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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