strings

package
v0.0.0-...-16b3867 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NO_DATA = "\u0000"

NO_DATA is used as a marker value to show that no data was provided and that the data is not just missing. It is represented as unicode character NULL (\u0000)

Functions

func FirstNonEmpty

func FirstNonEmpty(data ...string) string

func IsStringUnicodePrintable

func IsStringUnicodePrintable(s string) bool

IsStringUnicodePrintable checks if all runes in a given string `s` are considered printable according to the Unicode standard.

The function iterates through each rune in the string using a sequence generator (`seq.RuneSeq`) and determines its printability using `IsUnicodePrintable`.

A string is considered printable if all of its constituent runes satisfy the criteria defined in `IsUnicodePrintable`.

Parameters:

  • s: The string to check for printable runes.

Returns:

  • bool: Returns true if all runes in the string are printable; otherwise, returns false.

func IsUnicodePrintable

func IsUnicodePrintable(r rune) bool

func Join

func Join[S fmt.Stringer](it iter.Seq[S], sep string) string

func MapString

func MapString[S fmt.Stringer](it iter.Seq[S]) iter.Seq[string]

func StringFunc

func StringFunc[S fmt.Stringer](s S) string

Types

type RunePredicate

type RunePredicate func(r rune) bool

RunePredicate is a function that takes a rune and returns a boolean.

func IsControl

func IsControl(next RunePredicate) RunePredicate

IsControl creates an IsRune that checks if a rune is a control character (Cc).

func IsEmoji

func IsEmoji(next RunePredicate) RunePredicate

func IsGraphic

func IsGraphic(next RunePredicate) RunePredicate

IsGraphic creates an IsRune that checks if a rune is a graphic character (includes letters, marks, numbers, punctuation, symbols, and spaces).

func IsLetter

func IsLetter(next RunePredicate) RunePredicate

IsLetter creates an IsRune that checks if a rune is a letter character (Lu, Ll, Lt, Lm, Lo).

func IsMark

func IsMark(next RunePredicate) RunePredicate

IsMark creates an IsRune that checks if a rune is a mark character (Mc, Me, Mn).

func IsNumber

func IsNumber(next RunePredicate) RunePredicate

IsNumber creates an IsRune that checks if a rune is a number character (Nd, Nl, No).

func IsOneOf

func IsOneOf(tables []*unicode.RangeTable, next RunePredicate) RunePredicate

IsOneOf creates an IsRune that checks if a rune belongs to any of the given unicode ranges.

func IsOtherPrivateUse

func IsOtherPrivateUse(next RunePredicate) RunePredicate

IsOtherPrivateUse creates a RunePredicate that checks if a rune is a private use character (Co), or matches the next predicate.

func IsOtherSurrogate

func IsOtherSurrogate(next RunePredicate) RunePredicate

IsOtherSurrogate creates a RunePredicate that checks if a rune is a surrogate character (Cs), or matches the next predicate.

func IsPrint

func IsPrint(next RunePredicate) RunePredicate

IsPrint creates an IsRune that checks if a rune is a printable character (includes letters, marks, numbers, punctuation, symbols, spaces, and some control characters).

func IsPrintable

func IsPrintable(next RunePredicate) RunePredicate

IsPrintable creates a RunePredicate that checks if a rune is not printable by combining multiple Unicode checks. It chains together several predicates to check for control characters, marks, line separators, paragraph separators, private use characters, and surrogate code points.

Parameters:

  • next: The next RunePredicate in the chain to be evaluated if none of the non-printable checks match

Returns:

  • RunePredicate: A function that returns true if the rune is not printable or if the next predicate returns true

func IsPunct

func IsPunct(next RunePredicate) RunePredicate

IsPunct creates an IsRune that checks if a rune is a punctuation character (Pc, Pd, Ps, Pe, Pi, Pf, Po).

func IsSepAny

func IsSepAny(next RunePredicate) RunePredicate

IsSepAny creates a RunePredicate that checks if a rune is any type of separator (spaces, lines, paragraphs), by chaining together IsSepSpace, IsSepLine, and IsSepParagraph predicates.

Parameters:

  • next: The next RunePredicate in the chain to be evaluated if none of the separators checks match

Returns:

  • RunePredicate: A function that returns true if the rune is any type of separator or if the next predicate returns true

func IsSepLine

func IsSepLine(next RunePredicate) RunePredicate

IsSepLine creates a RunePredicate that checks if a rune is a line separator (Zl), or matches the next predicate.

func IsSepParagraph

func IsSepParagraph(next RunePredicate) RunePredicate

IsSepParagraph creates a RunePredicate that checks if a rune is a paragraph separator (Zp), or matches the next predicate.

func IsSepSpace

func IsSepSpace(next RunePredicate) RunePredicate

IsSepSpace creates a RunePredicate that checks if a rune is a space separator (Zs), or matches the next predicate.

Parameters:

  • next: The next RunePredicate in the chain to be evaluated if the space separator check doesn't match

Returns:

  • RunePredicate: A function that returns true if the rune is a space separator or if the next predicate returns true

func IsSpace

func IsSpace(next RunePredicate) RunePredicate

IsSpace creates an IsRune that checks if a rune is a space character (Zs, Zl, Zp).

func IsSymbol

func IsSymbol(next RunePredicate) RunePredicate

IsSymbol creates an IsRune that checks if a rune is a symbol character (Sm, Sc, Sk, So).

type Stringifier

type Stringifier[T any] func(t T) string

Jump to

Keyboard shortcuts

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