Documentation ¶
Overview ¶
Package charset provides data types and functions for managing sets of characters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set struct { // Bits is the bit array for indicating which chars are in the set. // We have 256 bits because a char can have 256 different values. Bits [4]uint64 }
A Set represents a set of chars.
func New ¶
New returns a charset which accepts all chars in 'chars'. Note that all chars must be valid ASCII characters (<128).
func Range ¶
CharsetRange returns a charset matching all characters between `low` and `high` inclusive.
func (Set) Complement ¶
Complement returns a charset that matches all characters except for those matched by `c`.
func (Set) IsSmall ¶
IsSmall returns true if this set can be converted to a small set. In other words, if this set only matches bytes <128.
type SmallSet ¶
type SmallSet struct {
Bits [2]uint64
}
A SmallSet is the same as a Set but can only represent 128 possible chars. This is an optimization, since in the common case, only ASCII bytes are used which are <128. The full Set is only necessary when unicode control characters must be matched.