fold

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fold implements the simple Unicode case-folding shared by the public github.com/gechr/x/strings and github.com/gechr/x/bytes packages. It sits below them so both fold identically - the same orbit canonicaliser and the same rune-scanning traversal - without duplicating that logic and without an import cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare[T Text](a, b T) int

Compare compares `a` and `b` case-insensitively under simple case-folding and returns -1, 0, or 1 following the cmp.Compare convention. `Compare(a, b)` is 0 iff `a` and `b` are equal under strings.EqualFold/bytes.EqualFold.

func Contains

func Contains[T Text](s, substr T) bool

Contains reports whether `s` contains `substr`, case-insensitively under simple case-folding.

func HasPrefix

func HasPrefix[T Text](s, prefix T) bool

HasPrefix reports whether `s` begins with `prefix`, case-insensitively under simple case-folding.

func HasSuffix

func HasSuffix[T Text](s, suffix T) bool

HasSuffix reports whether `s` ends with `suffix`, case-insensitively under simple case-folding.

func Rune

func Rune(r rune) rune

Rune maps `r` to the canonical (smallest) member of its case-fold orbit, so two runes have equal keys iff they are equal under simple case-folding. unicode.ToLower alone misses orbit members with distinct lowercase forms, for example Greek final sigma 'ς' vs 'σ'.

Types

type Text

type Text interface {
	string | []byte
}

Text is the set of concrete types the fold helpers operate on. It lists `string` and `[]byte` exactly, rather than `~string | ~[]byte`, so the `any(s).(type)` switches that dispatch to the string- or byte-specific `utf8`/`EqualFold` primitives stay exhaustive.

Jump to

Keyboard shortcuts

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