Small script to re-encode files that need it to UTF-8
This requires 'iconv' and that 'file' can take the options '-b' and '-i'.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit f608b4064d
)
This commit is contained in:
parent
2794dec7b2
commit
13e742a439
1 changed files with 17 additions and 0 deletions
17
util/toutf8.sh
Normal file
17
util/toutf8.sh
Normal file
|
@ -0,0 +1,17 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# Very simple script to detect and convert files that we want to re-encode to UTF8
|
||||
|
||||
git ls-tree -r --name-only HEAD | \
|
||||
while read F; do
|
||||
charset=`file -bi "$F" | sed -e 's|.*charset=||'`
|
||||
if [ "$charset" != "utf-8" -a "$charset" != "binary" -a "$charset" != "us-ascii" ]; then
|
||||
iconv -f ISO-8859-1 -t UTF8 < "$F" > "$F.utf8" && \
|
||||
( cmp -s "$F" "$F.utf8" || \
|
||||
( echo "$F"
|
||||
mv "$F" "$F.iso-8859-1"
|
||||
mv "$F.utf8" "$F"
|
||||
)
|
||||
)
|
||||
fi
|
||||
done
|
Loading…
Reference in a new issue