bidi_gettype.c 639 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Standalone test program that exposes the minibidi getType function.
  3. */
  4. #include <stdio.h>
  5. #include <assert.h>
  6. #include "putty.h"
  7. #include "misc.h"
  8. #include "bidi.h"
  9. void out_of_memory(void)
  10. {
  11. fprintf(stderr, "out of memory!\n");
  12. exit(2);
  13. }
  14. #define TYPETONAME(X) #X,
  15. static const char *const typenames[] = { BIDI_CHAR_TYPE_LIST(TYPETONAME) };
  16. #undef TYPETONAME
  17. int main(int argc, char **argv)
  18. {
  19. int i;
  20. for (i = 1; i < argc; i++) {
  21. unsigned long chr = strtoul(argv[i], NULL, 0);
  22. int type = bidi_getType(chr);
  23. printf("U+%04x: %s\n", (unsigned)chr, typenames[type]);
  24. }
  25. return 0;
  26. }