#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("");
}
|