* readline.scm: moved to ./ice-9/
[bpt/guile.git] / srfi / srfi-14.scm
CommitLineData
6be07c52
TTN
1;;; srfi-14.scm --- Character-set Library
2
3;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
4;;
73be1d9e
MV
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.
9;;
10;; This library is distributed in the hope that it will be useful,
6be07c52
TTN
11;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
73be1d9e
MV
13;; Lesser General Public License for more details.
14;;
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
ead45146
TTN
18
19;;; Commentary:
20
21;; This module is fully documented in the Guile Reference Manual.
22
23;;; Code:
ca003b26 24
1a179b03
MD
25(define-module (srfi srfi-14)
26 :export (
ca003b26
MG
27;;; General procedures
28 char-set?
29 char-set=
30 char-set<=
31 char-set-hash
32
33;;; Iterating over character sets
34 char-set-cursor
35 char-set-ref
36 char-set-cursor-next
37 end-of-char-set?
38 char-set-fold
39 char-set-unfold char-set-unfold!
40 char-set-for-each
41 char-set-map
42
43;;; Creating character sets
44 char-set-copy
45 char-set
46 list->char-set list->char-set!
8b19021c 47 string->char-set string->char-set!
ca003b26
MG
48 char-set-filter char-set-filter!
49 ucs-range->char-set ucs-range->char-set!
50 ->char-set
51
52;;; Querying character sets
53 char-set-size
54 char-set-count
55 char-set->list
56 char-set->string
57 char-set-contains?
58 char-set-every
59 char-set-any
60
61;;; Character set algebra
62 char-set-adjoin char-set-adjoin!
63 char-set-delete char-set-delete!
64 char-set-complement
65 char-set-union
66 char-set-intersection
67 char-set-difference
68 char-set-xor
69 char-set-diff+intersection
70 char-set-complement!
71 char-set-union!
72 char-set-intersection!
73 char-set-difference!
74 char-set-xor!
75 char-set-diff+intersection!
76
77;;; Standard character sets
78 char-set:lower-case
79 char-set:upper-case
80 char-set:title-case
81 char-set:letter
82 char-set:digit
83 char-set:letter+digit
84 char-set:graphic
85 char-set:printing
86 char-set:whitespace
87 char-set:iso-control
88 char-set:punctuation
89 char-set:symbol
90 char-set:hex-digit
91 char-set:blank
92 char-set:ascii
93 char-set:empty
94 char-set:full
1a179b03 95 ))
ca003b26 96
1b2f40b9
MG
97(cond-expand-provide (current-module) '(srfi-14))
98
dd22a80a 99(load-extension "libguile-srfi-srfi-13-14" "scm_init_srfi_14")
ca003b26
MG
100
101(define (->char-set x)
102 (cond
103 ((string? x) (string->char-set x))
104 ((char? x) (char-set x))
105 ((char-set? x) x)
106 (else (error "invalid argument to `->char-set'"))))
107
108(define char-set:full (ucs-range->char-set 0 256))
109
110(define char-set:lower-case (char-set-filter char-lower-case? char-set:full))
111
112(define char-set:upper-case (char-set-filter char-upper-case? char-set:full))
113
114(define char-set:title-case (char-set))
115
116(define char-set:letter (char-set-union char-set:lower-case
117 char-set:upper-case))
118
119(define char-set:digit (string->char-set "0123456789"))
120
121(define char-set:letter+digit
122 (char-set-union char-set:letter char-set:digit))
123
124(define char-set:punctuation (string->char-set "!\"#%&'()*,-./:;?@[\\]_{}"))
125
126(define char-set:symbol (string->char-set "$+<=>^`|~"))
127
128(define char-set:whitespace (char-set #\space #\newline #\tab #\cr #\vt #\np))
129
130(define char-set:blank (char-set #\space #\tab))
131
132(define char-set:graphic
133 (char-set-union char-set:letter+digit char-set:punctuation char-set:symbol))
134
135(define char-set:printing
136 (char-set-union char-set:graphic char-set:whitespace))
137
138(define char-set:iso-control
139 (char-set-adjoin
140 (char-set-filter (lambda (ch) (< (char->integer ch) 31)) char-set:full)
141 (integer->char 127)))
142
143(define char-set:hex-digit (string->char-set "0123456789abcdefABCDEF"))
144
145(define char-set:ascii
146 (char-set-filter (lambda (ch) (< (char->integer ch) 128)) char-set:full))
147
148(define char-set:empty (char-set))
ead45146
TTN
149
150;;; srfi-14.scm ends here