summaryrefslogtreecommitdiffstats
path: root/src/isutf8.sh
blob: ad27650eeb8a6d56dd4793f7dafdc3e605765e5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

# written by Ville Skyttä
# pulled in from http://fedoraproject.org/wiki/PackageMaintainers/UsefulScripts

VERBOSE=

while [ -n "$1" ] ; do
    [ "$1" = "-v" ] && { VERBOSE=1 ; shift ; continue ; }
    [ -f "$1" ] || { [ -n "$VERBOSE" ] && echo "???: $1" ; shift ; continue ; }

    cat="cat"
    case "$1" in 
       *.bz|*.bz2) cat="bzip2 -dcf" ;; 
       *.gz) cat="gzip -dcf" ;;
    esac

    if $cat "$1" | iconv -f utf-8 -t utf-8 >/dev/null 2>&1 ; then
        [ -n "$VERBOSE" ] && echo "yes: $1"
    else
        echo " NO: $1"
    fi

    shift
done