ctype.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 lub_ctype_isdigit(
  51. /**
  52. * The character to check
  53. */
  54. char c);
  55. /**
  56. * This operation identifies whether a character is a standard white space
  57. * character. (space, tab, carriage-return, vertical tab, form-feed)
  58. *
  59. * \pre
  60. * - none
  61. *
  62. * \return
  63. * BOOL_TRUE - if the character is white space
  64. * BOOL_FALSE - if the character is not white space
  65. *
  66. * \post
  67. * - none
  68. */
  69. bool_t lub_ctype_isspace(
  70. /**
  71. * The character to check
  72. */
  73. char c);
  74. /**
  75. * This operation converts an uppercase letter to the corresponding
  76. * lowercase letter.
  77. *
  78. * \pre
  79. * - none
  80. *
  81. * \return
  82. * If the parameter is a character for which lub_ctype_isupper() is true
  83. * and there is a corresponding character for which lub_ctype_islower() is true
  84. * then the corresponding character is returned. Otherwise the parameter is
  85. * returned unchanged.
  86. *
  87. * \post
  88. * - none
  89. */
  90. char lub_ctype_tolower(
  91. /**
  92. * The character to convert
  93. */
  94. char c);
  95. /**
  96. * This operation converts a lowercase letter to the corresponding
  97. * uppercase letter.
  98. *
  99. * \pre
  100. * - none
  101. *
  102. * \return
  103. * If the parameter is a character for which lub_ctype_islower() is true
  104. * and there is a corresponding character for which lub_ctype_isupper() is true
  105. * then the corresponding character is returned. Otherwise the parameter is
  106. * returned unchanged.
  107. *
  108. * \post
  109. * - none
  110. */
  111. char lub_ctype_toupper(
  112. /**
  113. * The character to convert
  114. */
  115. char c);
  116. _END_C_DECL
  117. #endif /* _lub_ctype_h */
  118. /** @} */