From: Hugo Villeneuve Date: Fri, 3 Dec 2021 19:05:23 +0000 (-0500) Subject: Add iso8859-to-utf8.sh X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=59fb465bf6817676c612161fb57af10d0381120a;p=hvutilities.git Add iso8859-to-utf8.sh --- diff --git a/scripts/Makefile.am b/scripts/Makefile.am index b885496..0be64ab 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -12,6 +12,7 @@ dist_bin_SCRIPTS = \ gztobz2 tarbz2 \ hv-backup \ hv-video-dvd \ + iso8859-to-utf8.sh \ mail-files mail-if-fail mail-statistics \ replace.pl \ rotatelogs \ diff --git a/scripts/iso8859-to-utf8.sh b/scripts/iso8859-to-utf8.sh new file mode 100755 index 0000000..6937e9f --- /dev/null +++ b/scripts/iso8859-to-utf8.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +TMPFILE=/tmp/iso8859-to-utf8.tmp + +if [ ${#} -eq 0 ]; then + echo "Erreur: aucun fichier(s) à traiter." + exit 1 +fi + +for f in ${*} ; do + if [ ! -f "${f}" ]; then + echo "Erreur: fichier introuvable: ${f}" + exit 1 + fi + if file -i "${f}" | grep -q "iso-8859-1"; then + echo "[ISO-8859 -> UTF8] ${f}" + iconv -f iso-8859-1 -t utf-8 "${f}" > ${TMPFILE} + mv ${TMPFILE} "${f}" + fi +done + +rm -f ${TMPFILE}