-
-
Save lebensterben/a6fab5c94e61d6ca67d9bdc0d149c504 to your computer and use it in GitHub Desktop.
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
#-*- mode: shell-script -*- | |
# Get Unicode Representation of Given String(s) | |
#2utf() { | |
if [[ $# -eq 0 ]]; then | |
cat << EOF | |
Usage: to_unicode String [...] | |
Print the unicode representation of one or multiple strings. | |
At least one argument should be given, and if multiple arguments are given, they should be seperated by whitespaces. | |
Examples: | |
☠ -> '\xE2\x98\xa0' | |
吼 -> '\xe5\x90\xbc' | |
asdf -> '\x61\x73\x64\x66' | |
EOF | |
else | |
for i in $@; do | |
echo -n $i | od -An -tx1 | sed 's/\([0-9a-f]\)\{2\}/\\x&/g' | tr -d ' ' | |
done | |
unset i | |
fi | |
#} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment