ctype.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * ctype.h
  3. */
  4. /**
  5. \ingroup lub
  6. \defgroup lub_ctype ctype
  7. @{
  8. \brief The ANSI-C standard <ctype.h> interface works fine for strings
  9. containing characters encoded with the ASCII 7-bit coding. However
  10. when you use characters outside this range things start to get ambiguous.
  11. The default manner in which to represent a string in C is to use a
  12. "char *". (NB. this is a signed type) The interfaces presented
  13. in <ctype.h> take signed integers. When a character greater than 128 is
  14. passed as a "char" to isspace() (e.g. the british pound sign "£") then
  15. a negative value is passed into the function/macro. A typical
  16. implementation (e.g. VxWorks) may use the passed argument as an offset
  17. into a lookup table, negative values in this case cause problems...
  18. This utility provides an interface which avoids this ambiguity by passing
  19. "char" characters directly rather than converting to "int".
  20. This component currently only contains those operations which are required
  21. by the current CLISH/LUB implementations. It can be extended on an as needed
  22. basis.
  23. */
  24. /*---------------------------------------------------------------
  25. * HISTORY
  26. * 4-Sep-2006 Graeme McKerrell
  27. * Initial Version
  28. *---------------------------------------------------------------
  29. * Copyright (C) 2006 Newport Networks. All Rights Reserved.
  30. *--------------------------------------------------------------- */
  31. #ifndef _lub_ctype_h
  32. #define _lub_ctype_h
  33. #include "lub/types.h"
  34. #include "lub/c_decl.h"
  35. _BEGIN_C_DECL
  36. /**
  37. * This operation identifies whether a character is a decimal digit
  38. * or not.
  39. *
  40. * \pre
  41. * - none
  42. *
  43. * \return
  44. * BOOL_TRUE - if the character is a decimal digit
  45. * BOOL_FALSE - if the character is not a decimal digit
  46. *
  47. * \post
  48. * - none
  49. */
  50. bool_t
  51. lub_ctype_isdigit(
  52. /**
  53. * The character to check
  54. */
  55. char c
  56. );
  57. /**
  58. * This operation identifies whether a character is a standard white space
  59. * character. (space, tab, carriage-return, vertical tab, form-feed)
  60. *
  61. * \pre
  62. * - none
  63. *
  64. * \return
  65. * BOOL_TRUE - if the character is white space
  66. * BOOL_FALSE - if the character is not white space
  67. *
  68. * \post
  69. * - none
  70. */
  71. bool_t
  72. lub_ctype_isspace(
  73. /**
  74. * The character to check
  75. */
  76. char c
  77. );
  78. /**
  79. * This operation converts an uppercase letter to the corresponding
  80. * lowercase letter.
  81. *
  82. * \pre
  83. * - none
  84. *
  85. * \return
  86. * If the parameter is a character for which lub_ctype_isupper() is true
  87. * and there is a corresponding character for which lub_ctype_islower() is true
  88. * then the corresponding character is returned. Otherwise the parameter is
  89. * returned unchanged.
  90. *
  91. * \post
  92. * - none
  93. */
  94. char
  95. lub_ctype_tolower(
  96. /**
  97. * The character to convert
  98. */
  99. char c
  100. );
  101. /**
  102. * This operation converts a lowercase letter to the corresponding
  103. * uppercase letter.
  104. *
  105. * \pre
  106. * - none
  107. *
  108. * \return
  109. * If the parameter is a character for which lub_ctype_islower() is true
  110. * and there is a corresponding character for which lub_ctype_isupper() is true
  111. * then the corresponding character is returned. Otherwise the parameter is
  112. * returned unchanged.
  113. *
  114. * \post
  115. * - none
  116. */
  117. char
  118. lub_ctype_toupper(
  119. /**
  120. * The character to convert
  121. */
  122. char c
  123. );
  124. _END_C_DECL
  125. #endif /* _lub_ctype_h */
  126. /** @} */