#!/bin/sh
#set -x
set -e

help ()
{
    echo "$0 accepts only one parameter"
}

[ $# = 1  ] || help

notutf8 ()
{
    grep -m 1 "Content-Type: .*; charset=.*\n" "$1" | grep -qi "utf-8" && return 1 || return 0
}

if notutf8 "$1"
then
    echo "W: $1: was not UTF-8 encoded"
    msgconv -t utf-8 -o "$1" "$1"
else
    echo "I: $1: already UTF-8 encoded"
fi
