Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kkszysiu/edb860c510a27ca47bc409980d669307 to your computer and use it in GitHub Desktop.
Save kkszysiu/edb860c510a27ca47bc409980d669307 to your computer and use it in GitHub Desktop.
FILES=`find . -name "*.java"`
for f in $FILES
do
filename="${f%.*}"
if file -I $f | grep -wq "iso-8859-1" || file -I $f | grep -wq "us-ascii" ; then
echo -n "$f"
mkdir -p converted
cp $f ./converted
DIR=$(dirname "$f")
mkdir -p $DIR
if file -I $f | grep -wq "iso-8859-1" ; then
iconv -f cp936 -t UTF-8 $f > "${filename}_utf8.java"
fi
if file -I $f | grep -wq "us-ascii" ; then
iconv -f ascii -t UTF-8 $f > "${filename}_utf8.java"
fi
mv "${filename}_utf8.java" $f
echo ": CONVERTED TO UTF-8."
else
echo -n "$f : UTF-8 ALREADY."
echo ""
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment