#include <runetype.c>
#include <bio.h>
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;
Biobuf b;
ARGBEGIN{
default:
usage();
}ARGEND
Binit(&b, 1, OWRITE);
for(i = 0; i < argc; i++){
r = strtorune(argv[i]);
if(r == Runeerror){
Bflush(&b);
fprint(2, "bad rune\n");
continue;
}
print("%.4ux ", r);
if(isalpharune(r))
Bprint(&b, "alpha ");
if(istitlerune(r))
Bprint(&b, "title ");
if(isspacerune(r))
Bprint(&b, "space ");
if(islowerrune(r))
Bprint(&b, "lower %C(%.4ux) ", toupperrune(r), toupperrune(r));
if(isupperrune(r))
Bprint(&b, "upper %C(%.4ux) ", tolowerrune(r), tolowerrune(r));
if(isdigitrune(r))
Bprint(&b, "digit %d\n", digitrunevalue(r));
Bprint(&b, "\n");
}
Bterm(&b);
exits("");
}
|