* isutf8: Detect and reject overlong UTF-8 sequences. Closes: #440951
[moreutils.git] / check-isutf8
blobd2858d996996acf1660ea8c8a9aa0db2c5be4587
1 #!/bin/bash
2 # Bash needed for the character encodings below.
4 # Run checks for ./isutf8.
6 # Lars Wirzenius <liw@iki.fi>
8 failed=0
10 check() {
11 printf "$2" | ./isutf8 -q
12 ret=$?
13 if [ $ret != $1 ]; then
14 echo "Failure:"
15 echo " input: $2"
16 echo " expected: $1"
17 echo " got: $ret"
18 failed=1
22 check 0 ''
23 check 0 'a'
24 check 0 'ab'
25 check 0 '\xc2\xa9'
27 check 1 '\xc2'
28 check 1 '\xc2\x20'
29 check 1 '\x20\xc2'
30 check 1 '\300\200'
32 exit $failed