ctype 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. .TH CTYPE 2
  2. .SH NAME
  3. isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, isgraph, iscntrl, isascii, toascii, _toupper, _tolower, toupper, tolower \- ASCII character classification
  4. .SH SYNOPSIS
  5. .B #include <u.h>
  6. .br
  7. .B #include <libc.h>
  8. .br
  9. .B #include <ctype.h>
  10. .PP
  11. .if t .2C
  12. .B isalpha(c)
  13. .PP
  14. .B isupper(c)
  15. .PP
  16. .B islower(c)
  17. .PP
  18. .B isdigit(c)
  19. .PP
  20. .B isxdigit(c)
  21. .PP
  22. .B isalnum(c)
  23. .PP
  24. .B isspace(c)
  25. .PP
  26. .B ispunct(c)
  27. .PP
  28. .B isprint(c)
  29. .PP
  30. .B isgraph(c)
  31. .PP
  32. .B iscntrl(c)
  33. .PP
  34. .B isascii(c)
  35. .PP
  36. .B _toupper(c)
  37. .PP
  38. .B _tolower(c)
  39. .PP
  40. .B toupper(c)
  41. .PP
  42. .B tolower(c)
  43. .PP
  44. .B toascii(c)
  45. .if t .1C
  46. .SH DESCRIPTION
  47. These macros classify
  48. .SM ASCII\c
  49. -coded integer values
  50. by table lookup.
  51. Each is a predicate returning nonzero for true,
  52. zero for false.
  53. .I Isascii
  54. is defined on all integer values; the rest
  55. are defined only where
  56. .I isascii
  57. is true and on the single non-\c
  58. .SM ASCII
  59. value
  60. .BR EOF ;
  61. see
  62. .IR fopen (2).
  63. .TP "\w'isalnum 'u"
  64. .I isalpha
  65. .I c
  66. is a letter, a\-z or A\-Z
  67. .TP
  68. .I isupper
  69. .I c
  70. is an upper case letter, A\-Z
  71. .TP
  72. .I islower
  73. .I c
  74. is a lower case letter, a\-z
  75. .TP
  76. .I isdigit
  77. .I c
  78. is a digit, 0\-9
  79. .TP
  80. .I isxdigit
  81. .I c
  82. is a hexadecimal digit, 0\-9 or a\-f or A\-F
  83. .TP
  84. .I isalnum
  85. .I c
  86. is an alphanumeric character, a\-z or A\-Z or 0\-9
  87. .TP
  88. .I isspace
  89. .I c
  90. is a space, horizontal tab, newline, vertical tab, formfeed, or carriage return
  91. (0x20, 0x9, 0xA, 0xB, 0xC, 0xD)
  92. .TP
  93. .I ispunct
  94. .I c
  95. is a punctuation character
  96. (one of
  97. .L
  98. !"#$%&'()*+,-./:;<=>?@[\e]^_`{|}~\fR)
  99. .TP
  100. .I isprint
  101. .I c
  102. is a printing character, 0x20 (space)
  103. through 0x7E (tilde)
  104. .TP
  105. .I isgraph
  106. .I c
  107. is a visible printing character, 0x21 (exclamation) through 0x7E
  108. (tilde)
  109. .TP
  110. .I iscntrl
  111. .I c
  112. is a delete character, 0x7F,
  113. or ordinary control character, 0x0 through 0x1F
  114. .TP
  115. .I isascii
  116. .I c
  117. is an
  118. .SM ASCII
  119. character, 0x0 through 0x7F
  120. .PP
  121. .I Toascii
  122. is not a classification macro;
  123. it converts its argument to
  124. .SM ASCII
  125. range by
  126. .IR and ing
  127. with 0x7F.
  128. .PP
  129. If
  130. .I c
  131. is an upper case letter,
  132. .I tolower
  133. returns the lower case version of the character;
  134. otherwise it returns the original character.
  135. .I Toupper
  136. is similar, returning the upper case version of a character
  137. or the original character.
  138. .I Tolower
  139. and
  140. .I toupper
  141. are functions;
  142. .I _tolower
  143. and
  144. .I _toupper
  145. are corresponding macros which should only be used when it
  146. is known that the argument is upper case or lower case, respectively.
  147. .SH SOURCE
  148. .TF /sys/src/libc/port/ctype.c
  149. .TP
  150. .B /sys/include/ctype.h
  151. for the macros.
  152. .TP
  153. .B /sys/src/libc/port/ctype.c
  154. for the tables.
  155. .SH "SEE ALSO
  156. .IR isalpharune (2)
  157. .SH BUGS
  158. These macros are
  159. .SM ASCII \c
  160. -centric.