Golang bytes.ToUpperSpecial() function example

package bytes

ToUpperSpecial returns a copy of the input byte slice with all Unicode letters mapped to their upper case, giving priority to the special casing rules. (See http://golang.org/pkg/bytes/#ToUpperSpecial)

Golang bytes.ToUpperSpecial() function usage

 package main

 import (
 "fmt"
 "bytes"
 "unicode"
 )

 func main() {
 str := []byte("a funky şğüöıi string. pay attention to i")

 toupper := bytes.ToUpper(str)
 toupperspecial := bytes.ToUpperSpecial(unicode.AzeriCase, str)

 fmt.Println("Original : " + string(str))

 fmt.Println("ToUpper : " + string(toupper))
 fmt.Println("ToUpperSpecial " + string(toupperspecial))

 }

Output :

Original : a funky şğüöıi string. pay attention to i

ToUpper : A FUNKY ŞĞÜÖII STRING. PAY ATTENTION TO I

ToUpperSpecial A FUNKY ŞĞÜÖIİ STRİNG. PAY ATTENTİON TO İ

Reference :

http://golang.org/pkg/bytes/#ToUpperSpecial

http://golang.org/pkg/unicode/#SpecialCase

https://gist.github.com/roktas/8514975

Advertisement