Fix macro file 'serial' numbers for 'aclocal --install'.
[libiconv.git] / tests / check-ebcdic
blob1bad48d42aae823dccdbe633af55eb4d8afac167
1 #!/bin/sh
2 # Check of ICONV_EBCDIC_ZOS_UNIX environment variable.
3 set -e
4 host_os="$1"
5 iconv=../src/iconv_no_i18n
7 # This test is only meaningful when the EBCDIC encodings are included.
8 if $iconv -l | grep IBM-1047 > /dev/null; then
10 if test "${host_os}" = 'openedition' ; then
11 # On z/OS, make all the files 'untagged'
12 rm -f tmp-ok-lf tmp-ok-nel tmp-ok-x15 tmp-ok-x25
13 touch tmp-ok-lf
14 touch tmp-ok-nel
15 touch tmp-ok-x15
16 touch tmp-ok-x25
17 chtag -r tmp-ok-lf
18 chtag -r tmp-ok-nel
19 chtag -r tmp-ok-x15
20 chtag -r tmp-ok-x25
23 printf '\150\145\154\154\157\012' > tmp-ok-lf
24 printf '\150\145\154\154\157\302\205' > tmp-ok-nel
26 printf '\210\205\223\223\226\025' > tmp-ok-x15
27 printf '\210\205\223\223\226\045' > tmp-ok-x25
29 # Check that by default, EBCDIC 0x15 maps to U+0085.
30 unset ICONV_EBCDIC_ZOS_UNIX
32 $iconv -f UTF-8 -t IBM-1047 < tmp-ok-nel > tmp-out1
33 $iconv -f ASCII -t IBM-1047 < tmp-ok-lf > tmp-out2
34 cmp tmp-out1 tmp-ok-x15
35 cmp tmp-out2 tmp-ok-x25
37 $iconv -f IBM-1047 -t UTF-8 < tmp-ok-x15 > tmp-out1
38 $iconv -f IBM-1047 -t ASCII < tmp-ok-x25 > tmp-out2
39 cmp tmp-out1 tmp-ok-nel
40 cmp tmp-out2 tmp-ok-lf
42 # Check that with the ZOS_UNIX surface, EBCDIC 0x15 maps to U+000A.
44 $iconv -f ASCII -t IBM-1047/ZOS_UNIX < tmp-ok-lf > tmp-out1
45 $iconv -f UTF-8 -t IBM-1047/ZOS_UNIX < tmp-ok-nel > tmp-out2
46 cmp tmp-out1 tmp-ok-x15
47 cmp tmp-out2 tmp-ok-x25
49 $iconv -f IBM-1047/ZOS_UNIX -t ASCII < tmp-ok-x15 > tmp-out1
50 $iconv -f IBM-1047/ZOS_UNIX -t UTF-8 < tmp-ok-x25 > tmp-out2
51 cmp tmp-out1 tmp-ok-lf
52 cmp tmp-out2 tmp-ok-nel
54 # Check that the ZOS_UNIX surface can be used with //TRANSLIT and //IGNORE.
56 printf '\357\275\210\342\204\257\360\235\232\225\360\235\232\225\342\200\242\n' \
57 | $iconv -f UTF-8 -t IBM-1047/ZOS_UNIX/TRANSLIT > tmp-out1
58 cmp tmp-out1 tmp-ok-x15
60 printf 'hello\342\202\254\n' \
61 | $iconv -f UTF-8 -t IBM-1047/ZOS_UNIX/IGNORE > tmp-out1
62 cmp tmp-out1 tmp-ok-x15
64 # Check that with a specific environment variable, EBCDIC 0x15 maps to U+000A.
65 ICONV_EBCDIC_ZOS_UNIX=1
66 export ICONV_EBCDIC_ZOS_UNIX
68 $iconv -f ASCII -t IBM-1047 < tmp-ok-lf > tmp-out1
69 $iconv -f UTF-8 -t IBM-1047 < tmp-ok-nel > tmp-out2
70 cmp tmp-out1 tmp-ok-x15
71 cmp tmp-out2 tmp-ok-x25
73 $iconv -f IBM-1047 -t ASCII < tmp-ok-x15 > tmp-out1
74 $iconv -f IBM-1047 -t UTF-8 < tmp-ok-x25 > tmp-out2
75 cmp tmp-out1 tmp-ok-lf
76 cmp tmp-out2 tmp-ok-nel
78 rm -f tmp-in* tmp-out* tmp-ok*
81 exit 0