cases

package
v1.5.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2016 License: Apache-2.0, Apache-2.0, BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package cases provides general and language-specific case mappers.

Index

Constants

View Source
const UnicodeVersion = "9.0.0"

UnicodeVersion is the Unicode version from which the tables in this package are derived.

Variables

View Source
var (
	Supported language.Coverage
)

Functions

This section is empty.

Types

type Caser

type Caser struct {
	// contains filtered or unexported fields
}

A Caser transforms given input to a certain case. It implements transform.Transformer.

A Caser may be stateful and should therefore not be shared between goroutines.

func Fold

func Fold(opts ...Option) Caser

Fold returns a Caser that implements Unicode case folding. The returned Caser is stateless and safe to use concurrently by multiple goroutines.

Case folding does not normalize the input and may not preserve a normal form. Use the collate or search package for more convenient and linguistically sound comparisons. Use unicode/precis for string comparisons where security aspects are a concern.

func Lower

func Lower(t language.Tag, opts ...Option) Caser

Lower returns a Caser for language-specific lowercasing.

func Title

func Title(t language.Tag, opts ...Option) Caser

Title returns a Caser for language-specific title casing. It uses an approximation of the default Unicode Word Break algorithm.

func Upper

func Upper(t language.Tag, opts ...Option) Caser

Upper returns a Caser for language-specific uppercasing.

func (Caser) Bytes

func (c Caser) Bytes(b []byte) []byte

Bytes returns a new byte slice with the result of converting b to the case form implemented by c.

func (Caser) Reset

func (c Caser) Reset()

Reset resets the Caser to be reused for new input after a previous call to Transform.

func (Caser) String

func (c Caser) String(s string) string

String returns a string with the result of transforming s to the case form implemented by c.

func (Caser) Transform

func (c Caser) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error)

Transform implements the Transformer interface and transforms the given input to the case form implemented by c.

type Option

type Option func(o *options)

An Option is used to modify the behavior of a Caser.

var (
	// NoLower disables the lowercasing of non-leading letters for a title
	// caser.
	NoLower Option = noLower

	// Compact omits mappings in case folding for characters that would grow the
	// input. (Unimplemented.)
	Compact Option = compact
)

Jump to

Keyboard shortcuts

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