1 ;;; srfi-14.scm --- Character-set Library
3 ;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
5 ;; This library is free software; you can redistribute it and/or
6 ;; modify it under the terms of the GNU Lesser General Public
7 ;; License as published by the Free Software Foundation; either
8 ;; version 2.1 of the License, or (at your option) any later version.
10 ;; This library 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 ;; Lesser General Public License for more details.
15 ;; You should have received a copy of the GNU Lesser General Public
16 ;; License along with this library; if not, write to the Free Software
17 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ;; This module is fully documented in the Guile Reference Manual.
25 (define-module (srfi srfi-14)
27 ;;; General procedures
33 ;;; Iterating over character sets
39 char-set-unfold char-set-unfold!
43 ;;; Creating character sets
46 list->char-set list->char-set!
47 string->char-set string->char-set!
48 char-set-filter char-set-filter!
49 ucs-range->char-set ucs-range->char-set!
52 ;;; Querying character sets
61 ;;; Character set algebra
62 char-set-adjoin char-set-adjoin!
63 char-set-delete char-set-delete!
69 char-set-diff+intersection
72 char-set-intersection!
75 char-set-diff+intersection!
77 ;;; Standard character sets
97 (cond-expand-provide (current-module) '(srfi-14))
99 (load-extension "libguile-srfi-srfi-13-14" "scm_init_srfi_14")
101 (define (->char-set x)
103 ((string? x) (string->char-set x))
104 ((char? x) (char-set x))
106 (else (error "invalid argument to `->char-set'"))))
108 (define char-set:full (ucs-range->char-set 0 256))
110 (define char-set:lower-case (char-set-filter char-lower-case? char-set:full))
112 (define char-set:upper-case (char-set-filter char-upper-case? char-set:full))
114 (define char-set:title-case (char-set))
116 (define char-set:letter (char-set-union char-set:lower-case
117 char-set:upper-case))
119 (define char-set:digit (string->char-set "0123456789"))
121 (define char-set:letter+digit
122 (char-set-union char-set:letter char-set:digit))
124 (define char-set:punctuation (string->char-set "!\"#%&'()*,-./:;?@[\\]_{}"))
126 (define char-set:symbol (string->char-set "$+<=>^`|~"))
128 (define char-set:whitespace (char-set #\space #\newline #\tab #\cr #\vt #\np))
130 (define char-set:blank (char-set #\space #\tab))
132 (define char-set:graphic
133 (char-set-union char-set:letter+digit char-set:punctuation char-set:symbol))
135 (define char-set:printing
136 (char-set-union char-set:graphic char-set:whitespace))
138 (define char-set:iso-control
140 (char-set-filter (lambda (ch) (< (char->integer ch) 31)) char-set:full)
141 (integer->char 127)))
143 (define char-set:hex-digit (string->char-set "0123456789abcdefABCDEF"))
145 (define char-set:ascii
146 (char-set-filter (lambda (ch) (< (char->integer ch) 128)) char-set:full))
148 (define char-set:empty (char-set))
150 ;;; srfi-14.scm ends here