1 ;;;; srfi-14.scm --- SRFI-14 procedures for Guile
3 ;;;; Copyright (C) 2001 Free Software Foundation, Inc.
5 ;;;; This program is free software; you can redistribute it and/or
6 ;;;; modify it under the terms of the GNU General Public License as
7 ;;;; published by the Free Software Foundation; either version 2, or
8 ;;;; (at your option) any later version.
10 ;;;; This program is distributed in the hope that it will be useful,
11 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ;;;; General Public License for more details.
15 ;;;; You should have received a copy of the GNU General Public License
16 ;;;; along with this software; see the file COPYING. If not, write to
17 ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 ;;;; Boston, MA 02111-1307 USA
20 (define-module (srfi srfi-14))
23 ;;; General procedures
29 ;;; Iterating over character sets
35 char-set-unfold char-set-unfold!
39 ;;; Creating character sets
42 list->char-set list->char-set!
43 string->char-set string-char-set!
44 char-set-filter char-set-filter!
45 ucs-range->char-set ucs-range->char-set!
48 ;;; Querying character sets
57 ;;; Character set algebra
58 char-set-adjoin char-set-adjoin!
59 char-set-delete char-set-delete!
65 char-set-diff+intersection
68 char-set-intersection!
71 char-set-diff+intersection!
73 ;;; Standard character sets
93 (dynamic-call "scm_init_srfi_13_14" (dynamic-link "libguile-srfi-srfi-13-14"))
95 (define (->char-set x)
97 ((string? x) (string->char-set x))
98 ((char? x) (char-set x))
100 (else (error "invalid argument to `->char-set'"))))
102 (define char-set:full (ucs-range->char-set 0 256))
104 (define char-set:lower-case (char-set-filter char-lower-case? char-set:full))
106 (define char-set:upper-case (char-set-filter char-upper-case? char-set:full))
108 (define char-set:title-case (char-set))
110 (define char-set:letter (char-set-union char-set:lower-case
111 char-set:upper-case))
113 (define char-set:digit (string->char-set "0123456789"))
115 (define char-set:letter+digit
116 (char-set-union char-set:letter char-set:digit))
118 (define char-set:punctuation (string->char-set "!\"#%&'()*,-./:;?@[\\]_{}"))
120 (define char-set:symbol (string->char-set "$+<=>^`|~"))
122 (define char-set:whitespace (char-set #\space #\newline #\tab #\cr #\vt #\np))
124 (define char-set:blank (char-set #\space #\tab))
126 (define char-set:graphic
127 (char-set-union char-set:letter+digit char-set:punctuation char-set:symbol))
129 (define char-set:printing
130 (char-set-union char-set:graphic char-set:whitespace))
132 (define char-set:iso-control
134 (char-set-filter (lambda (ch) (< (char->integer ch) 31)) char-set:full)
135 (integer->char 127)))
137 (define char-set:hex-digit (string->char-set "0123456789abcdefABCDEF"))
139 (define char-set:ascii
140 (char-set-filter (lambda (ch) (< (char->integer ch) 128)) char-set:full))
142 (define char-set:empty (char-set))