2 # Complete check of a stateless encoding.
3 # Usage: check-stateless SRCDIR CHARSET
8 # iconv in one direction.
9 ./table-from "$charset" > tmp-"$charset".TXT
11 # iconv in the other direction.
12 ./table-to "$charset" | sort > tmp-"$charset".INVERSE.TXT
14 # Check 1: charmap and iconv forward should be identical.
15 cmp "${srcdir}"/"$charset".TXT tmp-"$charset".TXT 2> /dev/null
17 # Check 2: the difference between the charmap and iconv backward.
18 sed -e '/ .* 0x/d' < "${srcdir}"/"$charset".TXT > tmp-noprecomposed-"$charset".TXT
19 if test -f "${srcdir}"/"$charset".IRREVERSIBLE.TXT; then
20 cat tmp-noprecomposed-"$charset".TXT "${srcdir}"/"$charset".IRREVERSIBLE.TXT | sort | uniq -u > tmp-orig-"$charset".INVERSE.TXT
22 cp tmp-noprecomposed-"$charset".TXT tmp-orig-"$charset".INVERSE.TXT
24 cmp tmp-orig-"$charset".INVERSE.TXT tmp-"$charset".INVERSE.TXT 2> /dev/null
26 rm -f tmp-"$charset".TXT tmp-"$charset".INVERSE.TXT tmp-noprecomposed-"$charset".TXT tmp-orig-"$charset".INVERSE.TXT
29 # You can create the "$charset".TXT like this:
30 # ./table-from "$charset" > "$charset".TXT
31 # You can create the "$charset".IRREVERSIBLE.TXT like this:
32 # ./table-to "$charset" | sort > "$charset".INVERSE.TXT
33 # diff "$charset".TXT "$charset".INVERSE.TXT | grep '^[<>]' | sed -e 's,^. ,,' > "$charset".IRREVERSIBLE.TXT