8a4254b3df3d61f372b7514602bb175da3759c7a
[openssl.git] / util / toutf8.sh
1 #! /bin/sh
2 #
3 # Very simple script to detect and convert files that we want to re-encode to UTF8
4
5 git ls-tree -r --name-only HEAD | \
6     while read F; do
7         charset=`file -bi "$F" | sed -e 's|.*charset=||'`
8         if [ "$charset" != "utf-8" -a "$charset" != "binary" -a "$charset" != "us-ascii" ]; then
9             iconv -f ISO-8859-1 -t UTF8 < "$F" > "$F.utf8" && \
10                 ( cmp -s "$F" "$F.utf8" || \
11                         ( echo "$F"
12                           mv "$F" "$F.iso-8859-1"
13                           mv "$F.utf8" "$F"
14                         )
15                 )
16         fi
17     done