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.

ctype.cpp 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* ctype-style APIs.
  2. *
  3. * Copyright (C) 2012-2013 Reece H. Dunn
  4. *
  5. * This file is part of ucd-tools.
  6. *
  7. * ucd-tools is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * ucd-tools is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with ucd-tools. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "ucd/ucd.h"
  21. int ucd::isalnum(codepoint_t c)
  22. {
  23. switch (lookup_category(c))
  24. {
  25. case Ll: case Lm: case Lo: case Lt: case Lu:
  26. case Nd: case Nl: case No:
  27. return 1;
  28. default:
  29. return 0;
  30. }
  31. }
  32. int ucd::isalpha(codepoint_t c)
  33. {
  34. switch (lookup_category(c))
  35. {
  36. case Ll: case Lm: case Lo: case Lt: case Lu:
  37. return 1;
  38. default:
  39. return 0;
  40. }
  41. }
  42. int ucd::iscntrl(codepoint_t c)
  43. {
  44. return lookup_category(c) == Cc;
  45. }
  46. int ucd::isdigit(codepoint_t c)
  47. {
  48. switch (lookup_category(c))
  49. {
  50. case Nd: case Nl: case No:
  51. return 1;
  52. default:
  53. return 0;
  54. }
  55. }
  56. int ucd::isgraph(codepoint_t c)
  57. {
  58. switch (lookup_category(c))
  59. {
  60. case Cc: case Cf: case Cn: case Co: case Cs:
  61. case Zl: case Zp: case Zs:
  62. case Ii:
  63. return 0;
  64. default:
  65. return 1;
  66. }
  67. }
  68. int ucd::islower(codepoint_t c)
  69. {
  70. return lookup_category(c) == Ll;
  71. }
  72. int ucd::isprint(codepoint_t c)
  73. {
  74. switch (lookup_category(c))
  75. {
  76. case Cc: case Cf: case Cn: case Co: case Cs:
  77. case Ii:
  78. return 0;
  79. default:
  80. return 1;
  81. }
  82. }
  83. int ucd::ispunct(codepoint_t c)
  84. {
  85. switch (lookup_category(c))
  86. {
  87. case Pc: case Pd: case Pe: case Pf: case Pi: case Po: case Ps:
  88. return 1;
  89. default:
  90. return 0;
  91. }
  92. }
  93. int ucd::isspace(codepoint_t c)
  94. {
  95. switch (lookup_category(c))
  96. {
  97. case Zl: case Zp: case Zs:
  98. return 1;
  99. case Cc:
  100. switch (c) // Some control characters are also whitespace characters:
  101. {
  102. case 0x09: // U+0009 : CHARACTER TABULATION
  103. case 0x0A: // U+000A : LINE FEED
  104. case 0x0B: // U+000B : LINE TABULATION
  105. case 0x0C: // U+000C : FORM FEED
  106. case 0x0D: // U+000D : CARRIAGE RETURN
  107. case 0x85: // U+0085 : NEXT LINE
  108. return 1;
  109. }
  110. default:
  111. return 0;
  112. }
  113. }
  114. int ucd::isupper(codepoint_t c)
  115. {
  116. return lookup_category(c) == Lu;
  117. }