char-alphabetic?, char-numeric?, etc - test character properties

LIBRARY

(import (rnrs))                     ;R6RS
(import (rnrs unicode))             ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme char))              ;R7RS

SYNOPSIS

(char-alphabetic? char)
(char-numeric? char)
(char-whitespace? char)
(char-upper-case? char)
(char-lower-case? char)
(char-title-case? char)             ;R6RS

DESCRIPTION

These procedures return #t if their arguments are alphabetic, numeric, whitespace, upper-case, lower-case, or title-case characters, respectively; otherwise they return #f.

A character is alphabetic if it has the Unicode "Alphabetic" property. A character is numeric if it has the Unicode "Numeric" property. A character is whitespace if has the Unicode "White_Space" property. A character is upper case if it has the Unicode "Uppercase" property, lower case if it has the "Lowercase" property, and title case if it is in the Lt general category.

R7RS notes that char-numeric? tests for "Numeric_Type=Decimal". Either way, it checks if the character is a decimal number.

RETURN VALUES

Returns a single boolean value.

EXAMPLES

(char-alphabetic? #\a)      =>  #t
(char-numeric? #\1)         =>  #t
(char-whitespace? #\space)  =>  #t

;; The following are not required to be supported in R7RS.
(char-numeric? #\x096A)     =>  #t
(char-whitespace? #\x00A0)  =>  #t
(char-upper-case? #\Σ)      =>  #t
(char-lower-case? #\σ)      =>  #t

COMPATIBILITY

Compatibility in R7RS systems depends on the implementation's supported character set. In systems that support Unicode, these procedures return different results depending on the supported Unicode version.

R5RS and earlier reports mention the proper semantics for ASCII, but implementations are free to use e.g. EBCDIC instead.

ERRORS

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

SEE ALSO

char->integer(3scm)

STANDARDS

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

AUTHORS

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/.


Markup created by unroff 1.0sc,    March 04, 2023.