eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

printucddata.cpp 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2012-2015 Reece H. Dunn
  3. *
  4. * This file is part of ucd-tools.
  5. *
  6. * ucd-tools is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * ucd-tools is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with ucd-tools. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "ucd/ucd.h"
  20. #include <stdio.h>
  21. void uprintf_codepoint(FILE *out, ucd::codepoint_t c, char mode)
  22. {
  23. switch (mode)
  24. {
  25. case 'h': // hexadecimal (lower)
  26. fprintf(out, "%06x", c);
  27. break;
  28. case 'H': // hexadecimal (upper)
  29. fprintf(out, "%06X", c);
  30. break;
  31. }
  32. }
  33. void uprintf(FILE *out, ucd::codepoint_t c, const char *format)
  34. {
  35. while (*format) switch (*format)
  36. {
  37. case '%':
  38. switch (*++format)
  39. {
  40. case 'c': // category
  41. fputs(ucd::get_category_string(ucd::lookup_category(c)), out);
  42. break;
  43. case 'C': // category group
  44. fputs(ucd::get_category_group_string(ucd::lookup_category_group(c)), out);
  45. break;
  46. case 'p': // codepoint
  47. uprintf_codepoint(out, c, *++format);
  48. break;
  49. case 'L': // lowercase
  50. uprintf_codepoint(out, ucd::tolower(c), *++format);
  51. break;
  52. case 's': // script
  53. fputs(ucd::get_script_string(ucd::lookup_script(c)), out);
  54. break;
  55. case 'T': // titlecase
  56. uprintf_codepoint(out, ucd::totitle(c), *++format);
  57. break;
  58. case 'U': // uppercase
  59. uprintf_codepoint(out, ucd::toupper(c), *++format);
  60. break;
  61. case 'W': // whitespace
  62. if (ucd::isspace(c))
  63. fputs("White_Space", out);
  64. break;
  65. }
  66. ++format;
  67. break;
  68. default:
  69. fputc(*format, out);
  70. ++format;
  71. break;
  72. }
  73. }
  74. int main()
  75. {
  76. for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c)
  77. uprintf(stdout, c, "%pH %s %C %c %UH %LH %TH %W\n");
  78. return 0;
  79. }