source: project/wiki/eggref/3/stringprep @ 13621

Last change on this file since 13621 was 13621, checked in by sjamaan, 11 years ago

Move old chicken 3 eggs over to eggref/3

File size: 3.7 KB
Line 
1==Introduction
2
3RFC 3454 Internationalized string preparation
4
5==Examples
6
7; XMPP Nodeprep profile
8
9(define nodeprep
10  (make-stringprepper
11    (list appendix-b1 appendix-b2) ; Mappings
12    #t ; Normalize
13    (char-set-union
14      appendix-c ; Forbid everything in Appendix C
15      (char-set #\" #\& #\' #\/ #\: #\< #\> #\@)) ; And this stuff
16    #t ; Bidirectional check))
17
18==Authors
19
20Adam C. Emerson <azure@umich.edu>
21
22==License
23
24This program is free software: you can redistribute it and/or modify
25it under the terms of the GNU General Public License as published by
26the Free Software Foundation, either version 3 of the License, or
27(at your option) any later version.
28
29This program is distributed in the hope that it will be useful,
30but WITHOUT ANY WARRANTY; without even the implied warranty of
31MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32GNU General Public License for more details.
33
34You should have received a copy of the GNU General Public License
35along with this program.  If not, see <http://www.gnu.org/licenses/>.
36
37==Requirements
38
39* [[utf8]]
40* [[unicode-normalization]]
41
42==make-stringprepper
43
44(make-stringprepper mappings normalize? prohibited bidi?)
45
46* mappings: list of mappings, where each mapping is either a char-set
47  (each character found in the set is mapped to nothing) or a sorted vector
48  (every element must be a pair with the car the character mapped from,
49  the cdr either a character mapped to or a list of characters.  The
50  must be sorted in ascending order by the car).
51
52* normalize?: If true, normalize the string into NFKC.
53
54* prohibited: char-set of prhobitied characters.  char-set-union is good
55  to use here.
56
57* bidi?: If true, do the bidirectionality check.  NOTE: The RFC requires
58  that the characters in appendix-c8 must be prohibited if this check is
59  performed.  Thus, you will get an error if this flag is true and
60  appendix-c8 is not a subset of your prohibited char-set.
61
62make-stringprepper returns a function from strings to strings.
63
64It will throw (exn invalid) if the string contains prohibited characters
65or fails the bidirectionality check.
66
67==appendix-b1
68
69Mapping given in Table B.1 of Appendix B, "Commonly mapped
70to nothing."
71
72==appendix-b2
73
74Mapping given in Table B.2 of Appendix B, "Mapping for case-folding used
75with NKFC."
76
77==appendix-b3
78
79Mapping given in Table B.3 of Appendix B, "Mapping for case-folding used
80with no normalization."
81
82==appendix-c1.1
83
84Character set given in Table C.1.1 of Appendix C, "ASCII space
85characters."
86
87==appendix-c1.2
88
89Character set given in Table C.1.2 of Appendix C, "Non-ASCII space
90characters."
91
92==appendix-c1
93
94Union of appendix-c1.1 and appendix-c1.2.
95
96==appendix-c2.1
97
98Character set given in Table C.2.1 of Appendix C, "ASCII control
99characters."
100
101==appendix-c2.2
102
103Character set given in Table C.2.2 of Appendix C, "Non-ASCII control
104characters."
105
106==appendic-c2
107
108Union of appendix-c2.1 and appendix-c2.2
109
110==appendix-c3
111
112Character set given in Table C.3 of Appendix C, "Private use"
113
114==appendix-c4
115
116Character set given in Table C.4 of Appendix C, "Non-character code
117points"
118
119==appendix-c5
120
121Character set given in Table C.5 of Appendix C, "Surrogate codes"
122
123==appendix-c6
124
125Character set given in Table C.6 of Appendix C, "Inappropriate for plain
126text"
127
128==appendix-c7
129
130Character set given in Table C.7 of Appendix C, "Inappropriate for
131canonical representation"
132
133==appendix-c8
134
135Character set given in Table C.8 of Appendix C, "Change display
136properties or are deprecated"
137
138==appendix-c9
139
140Character set given in Table C.9 of Appendix C, "Tagging characters"
141
142==appendix-c
143
144Union of appendix-c1, appendix-c2, appendix-c3, appendix-c4,
145appendix-c5, appendix-c6, appendix-c7, appendix-c8, and appendix-c9
146
147==Version History
148
149* 1.0 Initial Release
150* 1.1 Actually export appendix-c
Note: See TracBrowser for help on using the repository browser.