Debian Codegraph @

HTML/asciitable.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >ASCII Table</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
9 "><LINK
10 REL="HOME"
11 TITLE="Advanced Bash-Scripting Guide"
12 HREF="index.html"><LINK
13 REL="PREVIOUS"
14 TITLE="Copyright"
15 HREF="copyright.html"><LINK
16 REL="NEXT"
17 TITLE="Index"
18 HREF="xrefindex.html"><META
19 HTTP-EQUIV="Content-Style-Type"
20 CONTENT="text/css"><LINK
21 REL="stylesheet"
22 HREF="common/kde-common.css"
23 TYPE="text/css"><META
24 HTTP-EQUIV="Content-Type"
25 CONTENT="text/html; charset=iso-8859-1"><META
26 HTTP-EQUIV="Content-Language"
27 CONTENT="en"><LINK
28 REL="stylesheet"
29 HREF="common/kde-localised.css"
30 TYPE="text/css"
31 TITLE="KDE-English"><LINK
32 REL="stylesheet"
33 HREF="common/kde-default.css"
34 TYPE="text/css"
35 TITLE="KDE-Default"></HEAD
36 ><BODY
37 CLASS="APPENDIX"
38 BGCOLOR="#FFFFFF"
39 TEXT="#000000"
40 LINK="#AA0000"
41 VLINK="#AA0055"
42 ALINK="#AA0000"
43 STYLE="font-family: sans-serif;"
44 ><DIV
45 CLASS="NAVHEADER"
46 ><TABLE
47 SUMMARY="Header navigation table"
48 WIDTH="100%"
49 BORDER="0"
50 CELLPADDING="0"
51 CELLSPACING="0"
52 ><TR
53 ><TH
54 COLSPAN="3"
55 ALIGN="center"
56 >Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting</TH
57 ></TR
58 ><TR
59 ><TD
60 WIDTH="10%"
61 ALIGN="left"
62 VALIGN="bottom"
63 ><A
64 HREF="copyright.html"
65 ACCESSKEY="P"
66 >Prev</A
67 ></TD
68 ><TD
69 WIDTH="80%"
70 ALIGN="center"
71 VALIGN="bottom"
72 ></TD
73 ><TD
74 WIDTH="10%"
75 ALIGN="right"
76 VALIGN="bottom"
77 ><A
78 HREF="xrefindex.html"
79 ACCESSKEY="N"
80 >Next</A
81 ></TD
82 ></TR
83 ></TABLE
84 ><HR
85 ALIGN="LEFT"
86 WIDTH="100%"></DIV
87 ><DIV
88 CLASS="APPENDIX"
89 ><H1
90 ><A
91 NAME="ASCIITABLE"
92 ></A
93 >Appendix T. ASCII Table</H1
94 ><P
95 >Traditionally, a book of this sort has an <A
96 HREF="special-chars.html#ASCIIDEF"
97 >ASCII</A
98 > Table appendix.
99 This book does not. Instead, here are several short
100 scripts, each of which generates a complete ASCII table.</P
101 ><DIV
102 CLASS="EXAMPLE"
103 ><HR><A
104 NAME="ASCIISH"
105 ></A
106 ><P
107 ><B
108 >Example T-1. A script that generates an ASCII table</B
109 ></P
110 ><TABLE
111 BORDER="0"
112 BGCOLOR="#E0E0E0"
113 WIDTH="100%"
114 ><TR
115 ><TD
116 ><PRE
117 CLASS="PROGRAMLISTING"
118 > 1&nbsp;#!/bin/bash
119 2&nbsp;# ascii.sh
120 3&nbsp;# ver. 0.2, reldate 26 Aug 2008
121 4&nbsp;# Patched by ABS Guide author.
122 5&nbsp;
123 6&nbsp;# Original script by Sebastian Arming.
124 7&nbsp;# Used with permission (thanks!).
125 8&nbsp;
126 9&nbsp;exec &#62;ASCII.txt # Save stdout to file,
127 10&nbsp; #+ as in the example scripts
128 11&nbsp; #+ reassign-stdout.sh and upperconv.sh.
129 12&nbsp;
130 13&nbsp;MAXNUM=256
131 14&nbsp;COLUMNS=5
132 15&nbsp;OCT=8
133 16&nbsp;OCTSQU=64
134 17&nbsp;LITTLESPACE=-3
135 18&nbsp;BIGSPACE=-5
136 19&nbsp;
137 20&nbsp;i=1 # Decimal counter
138 21&nbsp;o=1 # Octal counter
139 22&nbsp;
140 23&nbsp;while [ "$i" -lt "$MAXNUM" ]; do # We don't have to count past 400 octal.
141 24&nbsp; paddi=" $i"
142 25&nbsp; echo -n "${paddi: $BIGSPACE} " # Column spacing.
143 26&nbsp; paddo="00$o"
144 27&nbsp;# echo -ne "\\${paddo: $LITTLESPACE}" # Original.
145 28&nbsp; echo -ne "\\0${paddo: $LITTLESPACE}" # Fixup.
146 29&nbsp;# ^
147 30&nbsp; echo -n " "
148 31&nbsp; if (( i % $COLUMNS == 0)); then # New line.
149 32&nbsp; echo
150 33&nbsp; fi
151 34&nbsp; ((i++, o++))
152 35&nbsp; # The octal notation for 8 is 10, and 64 decimal is 100 octal.
153 36&nbsp; (( i % $OCT == 0)) &#38;&#38; ((o+=2))
154 37&nbsp; (( i % $OCTSQU == 0)) &#38;&#38; ((o+=20))
155 38&nbsp;done
156 39&nbsp;
157 40&nbsp;exit $?
158 41&nbsp;
159 42&nbsp;# Compare this script with the "pr-asc.sh" example.
160 43&nbsp;# This one handles "unprintable" characters.
161 44&nbsp;
162 45&nbsp;# Exercise:
163 46&nbsp;# Rewrite this script to use decimal numbers, rather than octal.</PRE
164 ></TD
165 ></TR
166 ></TABLE
167 ><HR></DIV
168 ><DIV
169 CLASS="EXAMPLE"
170 ><HR><A
171 NAME="ASCII2SH"
172 ></A
173 ><P
174 ><B
175 >Example T-2. Another ASCII table script</B
176 ></P
177 ><TABLE
178 BORDER="0"
179 BGCOLOR="#E0E0E0"
180 WIDTH="100%"
181 ><TR
182 ><TD
183 ><PRE
184 CLASS="PROGRAMLISTING"
185 > 1&nbsp;#!/bin/bash
186 2&nbsp;# Script author: Joseph Steinhauser
187 3&nbsp;# Lightly edited by ABS Guide author, but not commented.
188 4&nbsp;# Used in ABS Guide with permission.
189 5&nbsp;
190 6&nbsp;#-------------------------------------------------------------------------
191 7&nbsp;#-- File: ascii.sh Print ASCII chart, base 10/8/16 (JETS-2012)
192 8&nbsp;#-------------------------------------------------------------------------
193 9&nbsp;#-- Usage: ascii [oct|dec|hex|help|8|10|16]
194 10&nbsp;#--
195 11&nbsp;#-- This script prints out a summary of ASCII char codes from Zero to 127.
196 12&nbsp;#-- Numeric values may be printed in Base10, Octal, or Hex.
197 13&nbsp;#--
198 14&nbsp;#-- Format Based on: /usr/share/lib/pub/ascii with base-10 as default.
199 15&nbsp;#-- For more detail, man ascii . . .
200 16&nbsp;#-------------------------------------------------------------------------
201 17&nbsp;
202 18&nbsp;[ -n "$BASH_VERSION" ] &#38;&#38; shopt -s extglob
203 19&nbsp;
204 20&nbsp;case "$1" in
205 21&nbsp; oct|[Oo]?([Cc][Tt])|8) Obase=Octal; Numy=3o;;
206 22&nbsp; hex|[Hh]?([Ee][Xx])|16|[Xx]) Obase=Hex; Numy=2X;;
207 23&nbsp; help|?(-)[h?]) sed -n '2,/^[ ]*$/p' $0;exit;;
208 24&nbsp; code|[Cc][Oo][Dd][Ee])sed -n '/case/,$p' $0;exit;;
209 25&nbsp; *) Obase=Decimal
210 26&nbsp;esac # CODE is actually shorter than the chart!
211 27&nbsp;
212 28&nbsp;printf "\t\t## $Obase ASCII Chart ##\n\n"; FM1="|%0${Numy:-3d}"; LD=-1
213 29&nbsp;
214 30&nbsp;AB="nul soh stx etx eot enq ack bel bs tab nl vt np cr so si dle"
215 31&nbsp;AD="dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us sp"
216 32&nbsp;
217 33&nbsp;for TOK in $AB $AD; do ABR[$((LD+=1))]=$TOK; done;
218 34&nbsp;ABR[127]=del
219 35&nbsp;
220 36&nbsp;IDX=0
221 37&nbsp;while [ $IDX -le 127 ] &#38;&#38; CHR="${ABR[$IDX]}"
222 38&nbsp; do ((${#CHR}))&#38;&#38; FM2='%-3s'|| FM2=`printf '\\\\%o ' $IDX`
223 39&nbsp; printf "$FM1 $FM2" "$IDX" $CHR; (( (IDX+=1)%8))||echo '|'
224 40&nbsp; done
225 41&nbsp;
226 42&nbsp;exit $?</PRE
227 ></TD
228 ></TR
229 ></TABLE
230 ><HR></DIV
231 ><DIV
232 CLASS="EXAMPLE"
233 ><HR><A
234 NAME="ASCII3SH"
235 ></A
236 ><P
237 ><B
238 >Example T-3. A third ASCII table script, using
239 <I
240 CLASS="FIRSTTERM"
241 >awk</I
242 ></B
243 ></P
244 ><TABLE
245 BORDER="0"
246 BGCOLOR="#E0E0E0"
247 WIDTH="100%"
248 ><TR
249 ><TD
250 ><PRE
251 CLASS="PROGRAMLISTING"
252 > 1&nbsp;#!/bin/bash
253 2&nbsp;# ASCII table script, using awk.
254 3&nbsp;# Author: Joseph Steinhauser
255 4&nbsp;# Used in ABS Guide with permission.
256 5&nbsp;
257 6&nbsp;
258 7&nbsp;#-------------------------------------------------------------------------
259 8&nbsp;#-- File: ascii Print ASCII chart, base 10/8/16 (JETS-2010)
260 9&nbsp;#-------------------------------------------------------------------------
261 10&nbsp;#-- Usage: ascii [oct|dec|hex|help|8|10|16]
262 11&nbsp;#--
263 12&nbsp;#-- This script prints a summary of ASCII char codes from Zero to 127.
264 13&nbsp;#-- Numeric values may be printed in Base10, Octal, or Hex (Base16).
265 14&nbsp;#--
266 15&nbsp;#-- Format Based on: /usr/share/lib/pub/ascii with base-10 as default.
267 16&nbsp;#-- For more detail, man ascii
268 17&nbsp;#-------------------------------------------------------------------------
269 18&nbsp;
270 19&nbsp;[ -n "$BASH_VERSION" ] &#38;&#38; shopt -s extglob
271 20&nbsp;
272 21&nbsp;case "$1" in
273 22&nbsp; oct|[Oo]?([Cc][Tt])|8) Obase=Octal; Numy=3o;;
274 23&nbsp; hex|[Hh]?([Ee][Xx])|16|[Xx]) Obase=Hex; Numy=2X;;
275 24&nbsp; help|?(-)[h?]) sed -n '2,/^[ ]*$/p' $0;exit;;
276 25&nbsp; code|[Cc][Oo][Dd][Ee])sed -n '/case/,$p' $0;exit;;
277 26&nbsp; *) Obase=Decimal
278 27&nbsp;esac
279 28&nbsp;export Obase # CODE is actually shorter than the chart!
280 29&nbsp;
281 30&nbsp;awk 'BEGIN{print "\n\t\t## "ENVIRON["Obase"]" ASCII Chart ##\n"
282 31&nbsp; ab="soh,stx,etx,eot,enq,ack,bel,bs,tab,nl,vt,np,cr,so,si,dle,"
283 32&nbsp; ad="dc1,dc2,dc3,dc4,nak,syn,etb,can,em,sub,esc,fs,gs,rs,us,sp"
284 33&nbsp; split(ab ad,abr,",");abr[0]="nul";abr[127]="del";
285 34&nbsp; fm1="|%0'"${Numy:- 4d}"' %-3s"
286 35&nbsp; for(idx=0;idx&#60;128;idx++){fmt=fm1 (++colz%8?"":"|\n")
287 36&nbsp; printf(fmt,idx,(idx in abr)?abr[idx]:sprintf("%c",idx))} }'
288 37&nbsp;
289 38&nbsp;exit $?</PRE
290 ></TD
291 ></TR
292 ></TABLE
293 ><HR></DIV
294 ></DIV
295 ><DIV
296 CLASS="NAVFOOTER"
297 ><HR
298 ALIGN="LEFT"
299 WIDTH="100%"><TABLE
300 SUMMARY="Footer navigation table"
301 WIDTH="100%"
302 BORDER="0"
303 CELLPADDING="0"
304 CELLSPACING="0"
305 ><TR
306 ><TD
307 WIDTH="33%"
308 ALIGN="left"
309 VALIGN="top"
310 ><A
311 HREF="copyright.html"
312 ACCESSKEY="P"
313 >Prev</A
314 ></TD
315 ><TD
316 WIDTH="34%"
317 ALIGN="center"
318 VALIGN="top"
319 ><A
320 HREF="index.html"
321 ACCESSKEY="H"
322 >Home</A
323 ></TD
324 ><TD
325 WIDTH="33%"
326 ALIGN="right"
327 VALIGN="top"
328 ><A
329 HREF="xrefindex.html"
330 ACCESSKEY="N"
331 >Next</A
332 ></TD
333 ></TR
334 ><TR
335 ><TD
336 WIDTH="33%"
337 ALIGN="left"
338 VALIGN="top"
339 >Copyright</TD
340 ><TD
341 WIDTH="34%"
342 ALIGN="center"
343 VALIGN="top"
344 >&nbsp;</TD
345 ><TD
346 WIDTH="33%"
347 ALIGN="right"
348 VALIGN="top"
349 >Index</TD
350 ></TR
351 ></TABLE
352 ></DIV
353 ></BODY
354 ></HTML
355 >