1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 // TODO: Add contextual character rules from Appendix A of RFC5892.
13 // A class is a set of characters that match certain derived properties. The
14 // PRECIS framework defines two classes: The Freeform class and the Identifier
15 // class. The freeform class should be used for profiles where expressiveness is
16 // prioritized over safety such as nicknames or passwords. The identifier class
17 // should be used for profiles where safety is the first priority such as
18 // addressable network labels and usernames.
23 // Contains satisfies the runes.Set interface and returns whether the given rune
24 // is a member of the class.
25 func (c class) Contains(r rune) bool {
27 n := utf8.EncodeRune(b, r)
29 trieval, _ := dpTrie.lookup(b[:n])
30 return c.validFrom <= property(trieval)
34 identifier = &class{validFrom: pValid}
35 freeform = &class{validFrom: idDisOrFreePVal}