1 # $MirOS: src/bin/mksh/check.t,v 1.465 2011/06/09 21:53:12 tg Exp $
3 # Copyright © 2008, 2009, 2011
4 # Thorsten Glaser <tg@mirbsd.org>
6 # Provided that these terms and disclaimer and all copyright notices
7 # are retained or reproduced in an accompanying document, permission
8 # is granted to deal in this work without restriction, including un‐
9 # limited rights to use, publicly perform, distribute, sell, modify,
10 # merge, give away, or sublicence.
12 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
13 # the utmost extent permitted by applicable law, neither express nor
14 # implied; without malicious intent or gross negligence. In no event
15 # may a licensor, author or contributor be held liable for indirect,
16 # direct, other damage, loss, or other issues arising in any way out
17 # of dealing in the work, even if advised of the possibility of such
18 # damage or existence of a defect, except proven that it results out
19 # of said person’s immediate fault when using the work as intended.
21 # hexdump, NUL byte and binary safe, Unicode (UCS-2, OPTU-16) output
23 # integer-base-one-3Wr
24 typeset -Uui16 -Z11 pos=0
25 typeset -Uui16 -Z7 hv=2147483647
27 if read -arN -1 line; then
30 while (( i < ${#line[*]} )); do
33 ((hv > 126) && (hv < 160)) )); then
35 elif (( (hv & 0xFF80) == 0xEF80 )); then
40 if (( (pos & 7) == 7 )); then
43 elif (( (pos & 7) == 0 )); then
44 (( pos )) && print "$dasc|"
45 print -n "${pos#16#} "
49 (( (pos++ & 7) == 3 )) && \
54 while (( pos & 7 )); do
56 (( (pos++ & 7) == 3 )) && print -n -- '- '
58 (( hv == 2147483647 )) || print "$dasc|"