toutf8.sh 472 B

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