Documentation
¶
Overview ¶
Package cases provides general and language-specific case mappers.
Example ¶
package main import ( "fmt" "golang.org/x/text/cases" "golang.org/x/text/language" ) func main() { src := []string{ "hello world!", "i with dot", "'n ijsberg", "here comes O'Brian", } for _, c := range []cases.Caser{ cases.Lower(language.Und), cases.Upper(language.Turkish), cases.Title(language.Dutch), cases.Title(language.Und, cases.NoLower), } { fmt.Println() for _, s := range src { fmt.Println(c.String(s)) } } }
Output: hello world! i with dot 'n ijsberg here comes o'brian HELLO WORLD! İ WİTH DOT 'N İJSBERG HERE COMES O'BRİAN Hello World! I With Dot 'n IJsberg Here Comes O'brian Hello World! I With Dot 'N Ijsberg Here Comes O'Brian
Index ¶
Examples ¶
Constants ¶
This section is empty.
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 Title ¶
Title returns a Caser for language-specific title casing. It uses an approximation of the default Unicode Word Break algorithm.
func (Caser) Bytes ¶
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.
Click to show internal directories.
Click to hide internal directories.