/*
 * 5799-WZQ (C) COPYRIGHT = NONE
 * LICENSED MATERIALS - PROPERTY OF IBM
 */
/* $Header:rdchar.c 12.0$ */
/* $ACIS:rdchar.c 12.0$ */
/* $Source: /ibm/acis/usr/src/usr.lib/lib2648/RCS/rdchar.c,v $ */

#ifndef lint
static char *rcsid = "$Header:rdchar.c 12.0$";
#endif

/*
 * Copyright (c) 1980 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */

#ifndef lint
static char sccsid[] = "@(#)rdchar.c	5.1 (Berkeley) 4/26/85";
#endif not lint

/*
 * rdchar: returns a readable representation of an ASCII char, using ^ notation.
 */

#include <ctype.h>

char *rdchar(c)
char c;
{
	static char ret[4];
	register char *p;

	/*
	 * Due to a bug in isprint, this prints spaces as ^`, but this is OK
	 * because we want something to show up on the screen.
	 */
	ret[0] = ((c&0377) > 0177) ? '\'' : ' ';
	c &= 0177;
	ret[1] = isprint(c) ? ' ' : '^';
	ret[2] = isprint(c) ?  c  : c^0100;
	ret[3] = 0;
	for (p=ret; *p==' '; p++)
		;
	return (p);
}
