From 59fb465bf6817676c612161fb57af10d0381120a Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Fri, 3 Dec 2021 14:05:23 -0500 Subject: [PATCH] Add iso8859-to-utf8.sh --- scripts/Makefile.am | 1 + scripts/iso8859-to-utf8.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 scripts/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} -- 2.20.1