1355:
33:
397:
For example, an array of 256 eight-bit integers, arranged as bitfields, is created, where each bit corresponds to a particular property of the character, e.g., isdigit, isalpha. If the lowest-order bit of the integers corresponds to the isdigit property, the code could be written as
294:. These functions are used to test characters for membership in a particular class of characters, such as alphabetic characters, control characters, etc. Both single-byte, and wide characters are supported.
394:
Unlike the above example, the character classification routines are not written as comparison tests. In most C libraries, they are written as static table lookups instead of macros or functions.
382:
As this may be expressed in multiple formulations, it became desirable to introduce short, standardized forms of such tests that were placed in the system-wide header file
882:
270:
97:
50:
69:
76:
83:
875:
1195:
65:
1359:
116:
263:
1176:
1085:
868:
1294:
427:
54:
1314:
1266:
1383:
1324:
1309:
1015:
256:
182:
90:
1271:
1319:
1025:
922:
917:
912:
172:
1299:
1010:
958:
891:
291:
177:
162:
1162:
1137:
43:
17:
1180:
1122:
840:
1142:
657:
197:
8:
1157:
1152:
1114:
1005:
167:
1223:
988:
953:
778:
593:
287:
132:
763:
748:
729:
710:
691:
672:
650:
631:
612:
586:
574:
555:
536:
517:
498:
1056:
1051:
1020:
963:
811:
741:
722:
703:
684:
665:
643:
624:
605:
567:
548:
529:
510:
491:
307:
192:
187:
157:
793:
422:
This can cause problems if when the macro expands, the expression substituted for
1167:
1127:
1035:
442:
is evaluated twice. For this reason, the table-based approach is generally used.
1340:
1185:
1147:
1073:
973:
314:
character set, the following expression identifies a letter, when its value is
1377:
1243:
1233:
1172:
1213:
978:
417:#define isdigit(x) ((x) >= '0' && (x) <= '9')
147:
1304:
860:
948:
927:
458:
in C++). The functions that operate on wide characters are defined in
310:
for classifying characters into different types. For example, for the
450:
The functions that operate on single-byte characters are defined in
32:
1248:
1238:
1218:
1063:
1030:
968:
469:
The classification is evaluated according to the effective locale.
412:
used a potentially faulty method similar to the first code sample:
242:
233:
215:
932:
224:
1203:
1100:
1095:
902:
1289:
1228:
1208:
1132:
1080:
1068:
409:
311:
1090:
303:
907:
286:
is an operation provided by a group of functions in the
678:
checks whether the operand is a blank space character
769:
checks whether the operand falls into specific class
438:. It is not immediately evident that the argument to
697:
checks whether the operand is a printable character
637:
checks whether the operand is a graphical character
57:. Unsourced material may be challenged and removed.
618:checks whether the operand is a control character
817:returns a transformation mapping to be used with
1375:
799:returns a wide character class to be used with
784:converts the operand using a specific mapping
876:
264:
302:Early C-language programmers working on the
561:checks whether the operand is an uppercase
504:checks whether the operand is alphanumeric
890:
883:
869:
716:checks whether the operand is punctuation
599:checks whether the operand is hexadecimal
271:
257:
523:checks whether the operand is alphabetic
117:Learn how and when to remove this message
542:checks whether the operand is lowercase
445:
14:
1376:
580:checks whether the operand is a digit
864:
55:adding citations to reliable sources
26:
24:
754:converts the operand to uppercase
735:converts the operand to lowercase
403:#define isdigit(x) (TABLE & 1)
25:
1395:
856:
389:
1354:
1353:
806:
788:
773:
758:
31:
842:ISO/IEC 9899:1999 specification
42:needs additional citations for
833:
656:checks whether the operand is
13:
1:
826:
430:. For example, if one calls
66:"C character classification"
7:
436:isdigit(run_some_program())
306:operating system developed
10:
1400:
1267:Compatibility of C and C++
297:
284:C character classification
1349:
1333:
1280:
1257:
1194:
1113:
1044:
996:
987:
941:
898:
414:
400:
320:
153:Character classification
288:ANSI C Standard Library
1272:Comparison with Pascal
892:C programming language
292:C programming language
446:Overview of functions
206:Miscellaneous headers
51:improve this article
1384:C standard library
408:Early versions of
308:programming idioms
198:Alternative tokens
133:C standard library
1369:
1368:
1109:
1108:
824:
823:
281:
280:
183:Memory allocation
168:File input/output
127:
126:
119:
101:
16:(Redirected from
1391:
1357:
1356:
994:
993:
989:Standard library
885:
878:
871:
862:
861:
850:
849:
848:. p. 193, § 7.4.
847:
837:
820:
814:
802:
796:
781:
766:
751:
744:
732:
725:
713:
706:
694:
687:
675:
668:
653:
646:
634:
627:
615:
608:
596:
589:
577:
570:
558:
551:
539:
532:
520:
513:
501:
494:
472:
471:
418:
404:
378:
375:
372:
369:
366:
363:
360:
357:
354:
351:
348:
345:
342:
339:
336:
333:
330:
327:
324:
273:
266:
259:
246:
237:
228:
219:
129:
128:
122:
115:
111:
108:
102:
100:
59:
35:
27:
21:
1399:
1398:
1394:
1393:
1392:
1390:
1389:
1388:
1374:
1373:
1370:
1365:
1345:
1329:
1282:
1276:
1260:other languages
1259:
1258:Comparison with
1253:
1190:
1128:Borland Turbo C
1105:
1045:Implementations
1040:
983:
937:
894:
889:
859:
854:
853:
845:
839:
838:
834:
829:
818:
810:
800:
792:
777:
762:
747:
740:
728:
721:
709:
702:
690:
683:
671:
664:
649:
642:
630:
623:
611:
604:
592:
585:
573:
566:
554:
547:
535:
528:
516:
509:
497:
490:
481:
476:
448:
420:
419:
416:
406:
405:
402:
392:
380:
379:
376:
373:
370:
367:
364:
361:
358:
355:
352:
349:
346:
343:
340:
337:
334:
331:
328:
325:
322:
300:
277:
240:
231:
222:
213:
188:Process control
123:
112:
106:
103:
60:
58:
48:
36:
23:
22:
15:
12:
11:
5:
1397:
1387:
1386:
1367:
1366:
1364:
1363:
1350:
1347:
1346:
1344:
1343:
1341:Dennis Ritchie
1337:
1335:
1331:
1330:
1328:
1327:
1322:
1317:
1312:
1307:
1302:
1297:
1292:
1286:
1284:
1278:
1277:
1275:
1274:
1269:
1263:
1261:
1255:
1254:
1252:
1251:
1246:
1241:
1236:
1231:
1226:
1221:
1216:
1211:
1206:
1200:
1198:
1192:
1191:
1189:
1188:
1183:
1170:
1165:
1160:
1155:
1150:
1145:
1140:
1135:
1130:
1125:
1119:
1117:
1111:
1110:
1107:
1106:
1104:
1103:
1098:
1093:
1088:
1083:
1078:
1077:
1076:
1066:
1061:
1060:
1059:
1048:
1046:
1042:
1041:
1039:
1038:
1033:
1028:
1023:
1018:
1016:Dynamic memory
1013:
1008:
1003:
997:
991:
985:
984:
982:
981:
976:
971:
966:
961:
956:
951:
945:
943:
939:
938:
936:
935:
930:
925:
920:
915:
910:
905:
899:
896:
895:
888:
887:
880:
873:
865:
858:
857:External links
855:
852:
851:
831:
830:
828:
825:
822:
821:
815:
808:
804:
803:
797:
790:
786:
785:
782:
775:
771:
770:
767:
760:
756:
755:
752:
745:
737:
736:
733:
726:
718:
717:
714:
707:
699:
698:
695:
688:
680:
679:
676:
669:
661:
660:
654:
647:
639:
638:
635:
628:
620:
619:
616:
609:
601:
600:
597:
590:
582:
581:
578:
571:
563:
562:
559:
552:
544:
543:
540:
533:
525:
524:
521:
514:
506:
505:
502:
495:
487:
486:
483:
478:
447:
444:
415:
401:
391:
390:Implementation
388:
321:
299:
296:
279:
278:
276:
275:
268:
261:
253:
250:
249:
248:
247:
238:
229:
220:
208:
207:
203:
202:
201:
200:
195:
190:
185:
180:
175:
170:
165:
160:
155:
150:
142:
141:
140:General topics
137:
136:
125:
124:
39:
37:
30:
9:
6:
4:
3:
2:
1396:
1385:
1382:
1381:
1379:
1372:
1362:
1361:
1352:
1351:
1348:
1342:
1339:
1338:
1336:
1332:
1326:
1323:
1321:
1318:
1316:
1313:
1311:
1308:
1306:
1303:
1301:
1298:
1296:
1293:
1291:
1288:
1287:
1285:
1279:
1273:
1270:
1268:
1265:
1264:
1262:
1256:
1250:
1247:
1245:
1244:Visual Studio
1242:
1240:
1237:
1235:
1234:GNOME Builder
1232:
1230:
1227:
1225:
1222:
1220:
1217:
1215:
1212:
1210:
1207:
1205:
1202:
1201:
1199:
1197:
1193:
1187:
1184:
1182:
1178:
1174:
1173:Visual Studio
1171:
1169:
1166:
1164:
1161:
1159:
1156:
1154:
1151:
1149:
1146:
1144:
1141:
1139:
1136:
1134:
1131:
1129:
1126:
1124:
1121:
1120:
1118:
1116:
1112:
1102:
1099:
1097:
1094:
1092:
1089:
1087:
1084:
1082:
1079:
1075:
1072:
1071:
1070:
1067:
1065:
1062:
1058:
1055:
1054:
1053:
1050:
1049:
1047:
1043:
1037:
1034:
1032:
1029:
1027:
1024:
1022:
1019:
1017:
1014:
1012:
1009:
1007:
1004:
1002:
999:
998:
995:
992:
990:
986:
980:
977:
975:
972:
970:
967:
965:
962:
960:
957:
955:
952:
950:
947:
946:
944:
940:
934:
931:
929:
926:
924:
921:
919:
916:
914:
911:
909:
906:
904:
901:
900:
897:
893:
886:
881:
879:
874:
872:
867:
866:
863:
844:
843:
836:
832:
816:
813:
809:
805:
798:
795:
791:
787:
783:
780:
776:
772:
768:
765:
761:
757:
753:
750:
746:
743:
739:
738:
734:
731:
727:
724:
720:
719:
715:
712:
708:
705:
701:
700:
696:
693:
689:
686:
682:
681:
677:
674:
670:
667:
663:
662:
659:
655:
652:
648:
645:
641:
640:
636:
633:
629:
626:
622:
621:
617:
614:
610:
607:
603:
602:
598:
595:
591:
588:
584:
583:
579:
576:
572:
569:
565:
564:
560:
557:
553:
550:
546:
545:
541:
538:
534:
531:
527:
526:
522:
519:
515:
512:
508:
507:
503:
500:
496:
493:
489:
488:
484:
479:
474:
473:
470:
467:
465:
462:header file (
461:
457:
454:header file (
453:
443:
441:
437:
433:
429:
425:
413:
411:
399:
395:
387:
385:
319:
317:
313:
309:
305:
295:
293:
289:
285:
274:
269:
267:
262:
260:
255:
254:
252:
251:
244:
239:
235:
230:
226:
221:
217:
212:
211:
210:
209:
205:
204:
199:
196:
194:
191:
189:
186:
184:
181:
179:
176:
174:
171:
169:
166:
164:
161:
159:
156:
154:
151:
149:
146:
145:
144:
143:
139:
138:
134:
131:
130:
121:
118:
110:
99:
96:
92:
89:
85:
82:
78:
75:
71:
68: –
67:
63:
62:Find sources:
56:
52:
46:
45:
40:This article
38:
34:
29:
28:
19:
1371:
1358:
1214:Code::Blocks
1186:Watcom C/C++
1000:
974:Preprocessor
954:Header files
841:
835:
485:Description
468:
463:
459:
455:
451:
449:
439:
435:
432:isdigit(x++)
431:
423:
421:
407:
396:
393:
383:
381:
315:
301:
283:
282:
178:Localization
152:
113:
107:October 2011
104:
94:
87:
80:
73:
61:
49:Please help
44:verification
41:
1305:Objective-C
1086:Windows CRT
428:side effect
374:'z'
356:'a'
344:'Z'
326:'A'
163:Mathematics
1281:Descendant
1153:Norcroft C
979:Data types
928:Embedded C
827:References
482:character
477:character
365:&&
335:&&
148:Data types
77:newspapers
1283:languages
1115:Compilers
1057:libhybris
959:Operators
949:Functions
819:towctrans
779:towctrans
594:iswxdigit
466:in C++).
173:Date/time
1378:Category
1360:Category
1334:Designer
1249:NetBeans
1239:KDevelop
1219:CodeLite
1064:dietlibc
1031:Variadic
1006:File I/O
942:Features
801:iswctype
764:iswctype
749:towupper
730:towlower
711:iswpunct
692:iswprint
673:iswblank
651:iswspace
632:iswgraph
613:iswcntrl
587:isxdigit
575:iswdigit
556:iswupper
537:iswlower
518:iswalpha
499:iswalnum
460:wctype.h
290:for the
243:stdarg.h
234:setjmp.h
216:assert.h
1224:Eclipse
1177:Express
933:MISRA C
812:wctrans
742:toupper
723:tolower
704:ispunct
685:isprint
666:isblank
644:isspace
625:isgraph
606:iscntrl
568:isdigit
549:isupper
530:islower
511:isalpha
492:isalnum
464:cwctype
452:ctype.h
440:isdigit
384:ctype.h
298:History
225:errno.h
193:Signals
158:Strings
91:scholar
18:Ctype.h
1204:Anjuta
1101:uClibc
1096:Newlib
1074:EGLIBC
1052:Bionic
1021:String
969:Syntax
964:String
903:ANSI C
794:wctype
456:cctype
426:has a
135:(libc)
93:
86:
79:
72:
64:
1315:Limbo
1229:Geany
1209:CLion
1133:Clang
1081:klibc
1069:glibc
1036:POSIX
846:(PDF)
658:space
410:Linux
371:<=
359:<=
341:<=
329:<=
312:ASCII
98:JSTOR
84:books
1325:Vala
1310:Alef
1196:IDEs
1163:SDCC
1091:musl
1026:Time
1011:Math
1001:Char
480:Wide
475:Byte
316:true
304:Unix
245:>
241:<
236:>
232:<
227:>
223:<
218:>
214:<
70:news
1290:C++
1181:C++
1168:TCC
1158:PCC
1148:LCC
1143:ICC
1138:GCC
1123:ACK
923:C23
918:C17
913:C11
908:C99
434:or
53:by
1380::
1320:Go
1295:C#
1179:,
1175:,
807:—
789:—
774:—
759:—
386:.
350:||
318::
1300:D
884:e
877:t
870:v
424:x
377:)
368:c
362:c
353:(
347:)
338:c
332:c
323:(
272:e
265:t
258:v
120:)
114:(
109:)
105:(
95:·
88:·
81:·
74:·
47:.
20:)
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.