collate

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2022 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLen is set for datum if the string datum don't know its length.
	DefaultLen = 0
)

Variables

This section is empty.

Functions

func CollationName2ID

func CollationName2ID(name string) int

CollationName2ID return the collation id by the given name. If the name is not found in the map, the default collation id is returned

func CompatibleCollate

func CompatibleCollate(collate1, collate2 string) bool

CompatibleCollate checks whether the two collate are the same.

func GetCollationByName

func GetCollationByName(name string) (coll *charset.Collation, err error)

GetCollationByName wraps charset.GetCollationByName, it checks the collation.

func IsCICollation

func IsCICollation(collate string) bool

IsCICollation returns if the collation is case-sensitive

func NewCollationEnabled

func NewCollationEnabled() bool

NewCollationEnabled returns if the new collations are enabled.

Types

type Collator

type Collator interface {
	// Compare returns an integer comparing the two strings. The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
	Compare(a, b string) int
	// Key returns the collate key for str. If the collation is padding, make sure the PadLen >= len(rune[]str) in opt.
	Key(str string) []byte
	// Pattern get a collation-aware WildcardPattern.
	Pattern() WildcardPattern
}

Collator provides functionality for comparing strings for a given collation order.

func GetCollator

func GetCollator(collate string) Collator

GetCollator get the collator according to collate, it will return the binary collator if the corresponding collator doesn't exist.

type WildcardPattern

type WildcardPattern interface {
	// Compile compiles the patternStr with specified escape character.
	Compile(patternStr string, escape byte)
	// DoMatch tries to match the str with compiled pattern, `Compile()` must be called before calling it.
	DoMatch(str string) bool
}

WildcardPattern is the interface used for wildcard pattern match.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL