xref: /original-bsd/old/lib2648/rdchar.c (revision 92d3de31)
1 /*	rdchar.c	4.1	83/03/09	*/
2 /*
3  * rdchar: returns a readable representation of an ASCII char, using ^ notation.
4  */
5 
6 #include <ctype.h>
7 
8 char *rdchar(c)
9 char c;
10 {
11 	static char ret[4];
12 	register char *p;
13 
14 	/*
15 	 * Due to a bug in isprint, this prints spaces as ^`, but this is OK
16 	 * because we want something to show up on the screen.
17 	 */
18 	ret[0] = ((c&0377) > 0177) ? '\'' : ' ';
19 	c &= 0177;
20 	ret[1] = isprint(c) ? ' ' : '^';
21 	ret[2] = isprint(c) ?  c  : c^0100;
22 	ret[3] = 0;
23 	for (p=ret; *p==' '; p++)
24 		;
25 	return (p);
26 }
27