summaryrefslogtreecommitdiffhomepage
path: root/tests/zos/ebcdic.sh
blob: 3920d60aadf753d9781546331d138d0ff64f409d (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
26
27
28
29
30
31
32
# z/OS, EBCDIC builds only: behaviour that depends on the character set.
# An ASCII build skips this test (status 77); its counterpart there is
# tests/posix/collate.ascii.sh.
#
# IBM-1047 facts used here: "A" is 0xC1 (octal 301), "a" is 0x81 (201),
# lower case sorts before upper case and digits after both, and the
# letters are not contiguous: 0x8A (212) lies between "i" (0x89) and
# "j" (0x91).
[ "$(printf '\301')" = A ] || exit 77

printf '\301\302\303\n'
x=$'\x81\x82'; echo "$x"

# Ranges are by position in the alphabet, so the gap is not a letter.
gap=$(printf '\212')
case $gap in [a-z]) echo "gap matches [a-z]" ;; *) echo "gap is not in [a-z]" ;; esac
case $gap in [[:alpha:]]) echo "gap is alpha" ;; *) echo "gap is not alpha" ;; esac
case j in [i-k]) echo "j in [i-k]" ;; esac
case r in [a-z]) echo "r in [a-z]" ;; esac

# Byte order: lower case before upper case, letters before digits.
[[ a < A ]] && echo "a sorts before A"
[[ Z < 0 ]] && echo "Z sorts before 0"
# Not `/bin/sort`: its collation comes from the environment, and on this
# system it puts digits first, which says nothing about the shell.

# Character codes, as printf and arithmetic see them.
printf '%d %d %d\n' "'A" "'a" "'0"

# Tests named *.ascii.sh are skipped in this build; the runner decides
# that with the same printf check as at the top of this file.
echo "EBCDIC build"