Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/runetype-x/trunetype.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <runetype.c>

Rune
strtorune(char *s)
{
	char *r;
	ulong u;

	u = strtoul(s, &r, 0x10);
	if(*r != 0 || u > Runemax)
		return Runeerror;
	return (Rune)u;
}

void
usage(void)
{
	fprint(2, "usage: trunetype [cp] ...\n");
	exits("usage");
}

void
main(int argc, char **argv)
{
	int i;
	Rune r;

	ARGBEGIN{
	default:
		usage();
	}ARGEND
	for(i = 0; i < argc; i++){
		r = strtorune(argv[i]);
		if(r == Runeerror){
			fprint(2, "bad rune\n");
			continue;
		}
		print("%.4ux ", r);
		if(isalpharune(r))
			print("alpha ");
		if(istitlerune(r))
			print("title ");
		if(isspacerune(r))
			print("space ");
		if(islowerrune(r))
			print("lower %C(%.4ux) ", toupperrune(r), toupperrune(r));
		if(isupperrune(r))
			print("upper %C(%.4ux) ", tolowerrune(r), tolowerrune(r));
		if(isdigitrune(r))
			print("digit %d\n", digitrunevalue(r));
		print("\n");
	}
	exits("");
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.