Check the encoding

_$: file fichero.txt
_$: file --mime-encoding fichero.php

Example: Recursively check the encoding of all files starting from the current directory.

check_encoding() {
    for file in $1/*
    do
        if [ -f $file ]
        then
            file --mime-encoding $file
        fi

        if [ -d $file ]
        then
            check_encoding $file
        fi
    done
}

check_encoding .

Change the encoding

_$: iconv -f WINDOWS-1252 \ # Original encoding
  -t UTF-8 \                # Target encoding
  filename.txt > filename-new-encoding.txt  # Original file > Target file