Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

lib/string-classify.x

Byte classification for canonical strings.

Primary API

FunctionSummary
String.contains_digitReports whether str contains a decimal digit.
String.is_alnumReports whether every byte of nonempty s is alphanumeric.
String.is_alnum_underReports whether nonempty s is alphanumeric or underscore.
String.is_alphaReports whether every byte of nonempty s is alphabetic.
String.is_alpha_underReports whether every byte of nonempty s is alphabetic or underscore.
String.is_digitReports whether every byte of nonempty s is a decimal digit.
String.is_identifierReports whether s is a C identifier under C character classes.
String.is_lowerReports whether every byte of nonempty s is lower-case.
String.is_lower_underReports whether every byte of nonempty s is lower-case or underscore.
String.is_spaceReports whether every byte of nonempty s is whitespace.
String.is_upperReports whether every byte of nonempty s is upper-case.
String.is_upper_underReports whether every byte of nonempty s is upper-case or underscore.

String

String.contains_digit

int String.contains_digit(String str)

Reports whether str contains a decimal digit. A null or empty String returns false.

Source: lib/string-classify.x:19

String.is_alnum

int String.is_alnum(String s)

Reports whether every byte of nonempty s is alphanumeric.

Source: lib/string-classify.x:53

String.is_alnum_under

int String.is_alnum_under(String s)

Reports whether nonempty s is alphanumeric or underscore.

Source: lib/string-classify.x:58

String.is_alpha

int String.is_alpha(String s)

Reports whether every byte of nonempty s is alphabetic.

Source: lib/string-classify.x:38

String.is_alpha_under

int String.is_alpha_under(String s)

Reports whether every byte of nonempty s is alphabetic or underscore.

Source: lib/string-classify.x:43

String.is_digit

int String.is_digit(String s)

Reports whether every byte of nonempty s is a decimal digit.

Source: lib/string-classify.x:48

String.is_identifier

int String.is_identifier(String s)

Reports whether s is a C identifier under C character classes. The first byte must be alphabetic or underscore; later bytes may also be decimal digits. A null or empty String returns false.

Source: lib/string-classify.x:66

String.is_lower

int String.is_lower(String s)

Reports whether every byte of nonempty s is lower-case.

Source: lib/string-classify.x:81

String.is_lower_under

int String.is_lower_under(String s)

Reports whether every byte of nonempty s is lower-case or underscore.

Source: lib/string-classify.x:86

String.is_space

int String.is_space(String s)

Reports whether every byte of nonempty s is whitespace.

Source: lib/string-classify.x:76

String.is_upper

int String.is_upper(String s)

Reports whether every byte of nonempty s is upper-case.

Source: lib/string-classify.x:91

String.is_upper_under

int String.is_upper_under(String s)

Reports whether every byte of nonempty s is upper-case or underscore.

Source: lib/string-classify.x:96

Design notes

Predicates classify unsigned bytes with C’s current locale. The canonical empty String is NULL and every predicate reports false for it. No predicate allocates or mutates its input.

Tests and examples

make verify (unittest/test-string-classify.x).