fix utf-8 format check

This commit is contained in:
vv01f 2020-07-23 11:29:28 +02:00
parent b428d17f20
commit 340c66086e
Signed by untrusted user who does not match committer: vv01f
GPG Key ID: 02625A16AC1D1FF6
1 changed files with 2 additions and 3 deletions

5
dhl.sh
View File

@ -164,7 +164,6 @@ testiso3 () {
testcmp "IND" "iso3countrycode" "Indien" "India" "Inde" "Bharat" testcmp "IND" "iso3countrycode" "Indien" "India" "Inde" "Bharat"
testcmp "CHN" "iso3countrycode" "China" "China" "Chine" "中国" "Zhōngguó" testcmp "CHN" "iso3countrycode" "China" "China" "Chine" "中国" "Zhōngguó"
testcmp "JPN" "iso3countrycode" "Japan" "Japan" "Japon" "Nippon" "Nihon" testcmp "JPN" "iso3countrycode" "Japan" "Japan" "Japon" "Nippon" "Nihon"
testcmp "" "iso3countrycode" "Simbabwe" # should fail testcmp "" "iso3countrycode" "Simbabwe" # should fail
} }
@ -236,8 +235,8 @@ convcsv () {
if test $# -eq 0 ; then >&2 echo "argument missing."; exit 1; fi if test $# -eq 0 ; then >&2 echo "argument missing."; exit 1; fi
# doc for headless conversion options https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options # doc for headless conversion options https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options
if="${1}" if="${1}"
format=$(file ${if}|cut -d':' -f2-|cut -d' ' -f2) format=$(file ${if}|rev|cut -d':' -f1|rev|cut -d' ' -f2)
if test "$format" != "UTF-8" ; then >&2 echo "source file encoding not matching the expected UTF-8."; fi if test "$format" != "UTF-8" ; then >&2 echo "source file encoding not matching 'UTF-8' as expected."; fi
of=$(echo "${if}"|rev|cut -d. -f2-|rev)".ods" of=$(echo "${if}"|rev|cut -d. -f2-|rev)".ods"
if test -e $of ; then >&2 echo "output file already exists."; exit 2; fi if test -e $of ; then >&2 echo "output file already exists."; exit 2; fi
#~ iconv -o "$of" -f $format -t cp1252//TRANSLIT "$if" #~ iconv -o "$of" -f $format -t cp1252//TRANSLIT "$if"