Skip to content

Instantly share code, notes, and snippets.

@tasoseng
Created March 27, 2021 00:26
Show Gist options
  • Save tasoseng/e5000768ea2cb11ba7dc6aeb23415927 to your computer and use it in GitHub Desktop.
Save tasoseng/e5000768ea2cb11ba7dc6aeb23415927 to your computer and use it in GitHub Desktop.
decode greek sms
#!/bin/sh
set -e
if [ -z $1 ]; then
echo "Usage: $0 file"
exit 1
fi
OS=$(uname -s)
if [ "${OS}" == "Linux" ]; then
SED=sed
elif [ "${OS}" == "FreeBSD" ]; then
SED=gsed
fi
echo '---------------------------------------------------'
echo $1
alphabet=$(grep ^Alphabet: $1| awk '{print $2}')
if [ "$alphabet" == "UTF-8" ]; then
cat $1 | ${SED} "y/\xc2\x80\xc2\x81\xc2\x82\xc2\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a/_ΔΦΓΛΩΠΨΣΘΞ/"
elif [ "$alphabet" == "ISO" ]; then
cat $1 | ${SED} "y/\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\xa4/_ΔΦΓΛΩΠΨΣΘΞ€/"
else
cat $1
fi
echo
echo '---------------------------------------------------'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment