Skip to content

Instantly share code, notes, and snippets.

@dustalov
Created September 13, 2016 20:25
Show Gist options
  • Save dustalov/86b26e05bb168acc524b6c4bbb100ba5 to your computer and use it in GitHub Desktop.
Save dustalov/86b26e05bb168acc524b6c4bbb100ba5 to your computer and use it in GitHub Desktop.
A brute force decoder of Cyrillic strings with unknown charset combination.
#!/bin/bash -e
S=$(head -1)
CHARSETS=(utf8 cp1251 cp1252 koi8r koi8u iso-8859-5 maccyrillic)
for c1 in ${CHARSETS[*]}; do
for c2 in ${CHARSETS[*]}; do
for c3 in ${CHARSETS[*]}; do
for c4 in ${CHARSETS[*]}; do
echo -ne "$c1\t$c2\t$c3\t$c4\t"
<<<$S iconv -f=$c1 -t=$c2 -c | iconv -f=$c3 -t=$c4 -c
done
done
done
done
@dustalov
Copy link
Author

./decoder.sh <file-with-weird-characters.txt | less

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment