For Gauche 0.9.5


Next: , Previous: , Up: Library modules - SRFIs   [Contents][Index]

11.7 srfi-14 - Character-set library

Module: srfi-14

Implements the character set library defined in SRFI-14 (SRFI-14). Note that the following character-set procedures are Gauche’s build-in. See Character set.

See Character set.

char-set char-set? char-set-contains? char-set-copy
char-set-complement char-set-complement!

In Gauche, the <char-set> class inherits <collection> and implements the collection protocol, so that the generic operations defined in gauche.collection can also be used (see Collection framework).


Next: , Previous: , Up: Character-set library   [Contents][Index]

11.7.1 Character-set constructors

Function: list->char-set char-list :optional base-cs
Function: list->char-set! char-list base-cs

[SRFI-14] Constructs a character set from a list of characters char-list. If base-cs is given, it must be a character set, and the characters in it are added to the result character set. List->char-set! is allowed, but not required, to reuse base-cs to store the result.

Function: string->char-set s :optional base-cs
Function: string->char-set! s base-cs

[SRFI-14] Like list->char-set and list->char-set!, but take a list of characters from a string s.

Function: char-set-filter pred char-set :optional base-cs
Function: char-set-filter! pred char-set base-cs

[SRFI-14] Returns a character set containing every character c in char-set such that (pred c) returns true. If a character set base-cs is given, its content is added to the result. The linear update version char-set-filter! is allowed, but not required, to modify base-cs to store the result.

Function: ucs-range->char-set lower upper :optional error? base-cs
Function: ucs-range->char-set! lower upper error? base-cs

[SRFI-14] Creates

Function: integer-range->char-set lower upper :optional error? base-cs
Function: integer-range->char-set! lower upper error? base-cs
Function: ->char-set x

[SRFI-14] A convenience function to coerce various kinds of objects to a char-set. The argument x can be a collection of characters, a char-set, or a character. If the argument is a char-set, it is returned as-is. If the argument is a character, a char-set with that single character is returned.

Note: SRFI-14’s ->char-set only accepts a string, a char-set or a character as an argument. Gauche extends it so that it can accept any collection of characters.


Next: , Previous: , Up: Character-set library   [Contents][Index]

11.7.2 Character-set comparison

Function: char-set= char-set1 …

[SRFI-14] Returns #t iff all the character sets have exactly the same members.

(char-set=)  ⇒ #t
(char-set= (char-set)) ⇒ #t
(char-set= (string->char-set "cba")
           (list->char-set #\a #\b #\c))
  ⇒ #t
Function: char-set<= char-set1 …

[SRFI-14]

Function: char-set-hash char-set :optional bound

[SRFI-14]


Next: , Previous: , Up: Character-set library   [Contents][Index]

11.7.3 Character-set iteration

Function: char-set-cursor char-set

[SRFI-14]

Function: char-set-ref char-set cursor

[SRFI-14]

Function: char-set-cursor-next char-set cursor

[SRFI-14]

Function: end-of-char-set? ccursor

[SRFI-14]

Function: char-set-fold kons knil char-set

[SRFI-14]

Function: char-set-unfold pred fun gen seed :optional base-char-set
Function: char-set-unfold! pred fun gen seed base-char-set

[SRFI-14]

Function: char-set-for-each proc char-set

[SRFI-14]

Function: char-set-map proc char-set

[SRFI-14]


Next: , Previous: , Up: Character-set library   [Contents][Index]

11.7.4 Character-set query

Function: char-set-every pred char-set
Function: char-set-any pred char-set
Function: char-set-count pred char-set

[SRFI-14] These procedures apply pred to each character in char-set.

char-set-every returns #f as soon as pred returns #f. Otherwise, it returns the result of the last application of pred.

char-set-any returns as soon as pred returns a true value, and the return value is the one pred returns. If pred returns #f for all characters, #f is returned.

char-set-count returns the number of times pred returns a true value.

Note that char-set can be huge (e.g. a complement of small char-set), which can make these procedures take very long.

Function: char-set->list char-set
Function: char-set->string char-set

[SRFI-14] Returns a list of each character, or a string consisting of each character, in char-set, respectively. Be careful to apply this on a large char set.


Next: , Previous: , Up: Character-set library   [Contents][Index]

11.7.5 Character-set algebra

Function: char-set-adjoin char-set char1 …
Function: char-set-adjoin! char-set char1 …

[SRFI-14] Returns a character set that adds char1 … to char-set.

Function: char-set-delete char-set char1 …
Function: char-set-delete! char-set char1 …

[SRFI-14]

Function: char-set-union char-set …
Function: char-set-union! char-set1 char-set2 …

[SRFI-14]

Function: char-set-intersection char-set …
Function: char-set-intersection! char-set1 char-set2 …

[SRFI-14]

Function: char-set-difference char-set1 char-set2 …
Function: char-set-difference! char-set1 char-set2 …

[SRFI-14]

Function: char-set-xor char-set …
Function: char-set-xor! char-set1 char-set2 …

[SRFI-14]

Function: char-set-diff+intersection char-set1 char-set2 …
Function: char-set-diff+intersection! char-set1 char-set2 char-set3 …

[SRFI-14]


Previous: , Up: Character-set library   [Contents][Index]

11.7.6 Predefined character-set

Variable: char-set:letter

[SRFI-14]

Variable: char-set:blank

[SRFI-14]

Variable: char-set:iso-control

[SRFI-14]

Variable: char-set:digit
Variable: char-set:hex-digit

[SRFI-14]

Variable: char-set:graphic

[SRFI-14]

Variable: char-set:lower-case
Variable: char-set:upper-case
Variable: char-set:title-case

[SRFI-14]

Variable: char-set:printing

[SRFI-14]

Variable: char-set:punctuation

[SRFI-14]

Variable: char-set:whitespace

[SRFI-14]

Variable: char-set:symbol

[SRFI-14]

Variable: char-set:ascii

[SRFI-14]

Variable: char-set:empty

[SRFI-14]

Variable: char-set:full

[SRFI-14]


Previous: , Up: Character-set library   [Contents][Index]