Created
July 2, 2017 13:17
-
-
Save kkszysiu/edb860c510a27ca47bc409980d669307 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
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