-
-
Save carlosspohr/789fb5a27211776f9d11 to your computer and use it in GitHub Desktop.
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
# verifica encoding do arquivo | |
$ file -I script_perebento.sql | |
$ file -bI script_perebento.sql | |
# converte arquivo de ISO-8859-1 para UTF-8 | |
$ iconv -f ISO-8859-1 -t UTF-8 script_perebento.sql > script_bonitao.sql |
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/bash | |
NON_UTF_FILE_DIR="WebRoot/WEB-INF/jsp" | |
PATTERN_FILE_NAME="*.jsp" | |
find $NON_UTF_FILE_DIR -type f -name $PATTERN_FILE_NAME > utf8list | |
iconv utf8list > asciilist | |
i=1 | |
for file in $(cat utf8list); do | |
newname=$(head -$i asciilist | tail -1 | tr -d '\n').utf8 | |
echo "converting file to utf-8 $file => $newname" | |
iconv -f ISO-8859-1 -t utf8 $file > $newname | |
mv $newname $file | |
let i++ | |
done | |
rm utf8list asciilist |
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/bash | |
NON_UTF_FILE_DIR="WebRoot" | |
PATTERN_FILE_NAME="*.jsp" | |
find $NON_UTF_FILE_DIR -type f -name $PATTERN_FILE_NAME > utf8list | |
iconv utf8list > asciilist | |
i=1 | |
for file in $(cat utf8list); do | |
CURRENT_CHARSET="$(file -bI "$file" | awk -F "=" '{print $2}')" | |
if [ "$CURRENT_CHARSET" == utf-8 ]; then | |
let i++ | |
continue | |
fi | |
newname=$(head -$i asciilist | tail -1 | tr -d '\n').utf8 | |
echo "converting file ($CURRENT_CHARSET) to utf-8 $file => $newname" | |
#iconv -f ISO-8859-1 -t utf8 $file > $newname | |
iconv -f "$CURRENT_CHARSET" -t utf8 $file > $newname | |
mv $newname $file | |
let i++ | |
done | |
rm utf8list asciilist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment