Documentation
¶
Overview ¶
Package casemap folds nicks and channel names to a canonical form per the negotiated CASEMAPPING token so that case-insensitive comparison works.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mapper ¶
Mapper folds a string to its canonical lowercase form.
var ASCII Mapper = func(s string) string { var b strings.Builder b.Grow(len(s)) for i := 0; i < len(s); i++ { c := s[i] if c >= 'A' && c <= 'Z' { c += 'a' - 'A' } b.WriteByte(c) } return b.String() }
ASCII folds the bytes A-Z to lowercase and leaves all other bytes unchanged.
var RFC1459 Mapper = func(s string) string { var b strings.Builder b.Grow(len(s)) for i := 0; i < len(s); i++ { c := s[i] switch c { case '{': c = '[' case '}': c = ']' case '|': c = '\\' case '^': c = '~' default: if c >= 'A' && c <= 'Z' { c += 'a' - 'A' } } b.WriteByte(c) } return b.String() }
RFC1459 folds ASCII letters and the classic { } | ^ equivalences to [ ] \ ~.
var RFC1459Strict Mapper = func(s string) string { var b strings.Builder b.Grow(len(s)) for i := 0; i < len(s); i++ { c := s[i] switch c { case '{': c = '[' case '}': c = ']' case '|': c = '\\' default: if c >= 'A' && c <= 'Z' { c += 'a' - 'A' } } b.WriteByte(c) } return b.String() }
RFC1459Strict folds the same characters as RFC1459 but omits the ^ to ~ fold.
RFC7613 folds using strings.ToLower as a dependency-free approximation of PRECIS UsernameCaseMapped that is consistent for comparison but skips NFC normalisation.
Click to show internal directories.
Click to hide internal directories.