Created
October 14, 2015 12:22
-
-
Save skunkie/9d66f0030c3771081b35 to your computer and use it in GitHub Desktop.
find non-ASCII characters in a string
This file contains hidden or 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/sh | |
usage(){ | |
echo " | |
find non-ASCII characters in a string | |
Usage: $0 STRING | |
" | |
exit 0 | |
} | |
if [ "$#" -ne 1 ]; then | |
usage | |
fi | |
array=$(echo "$1" | grep -o .) | |
for char in $array; do | |
if [ $(printf '%d' "'$char") -gt 127 ]; then | |
echo $char | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment