Golang bytes.ToTitle() function example
package bytes
ToTitle returns a copy of the byte input slice with all Unicode letters mapped to their title case.
Golang bytes.ToTitle() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
str := []byte("this is a title!")
title := bytes.Title(str) // for comparison purpose
totitle := bytes.ToTitle(str)
fmt.Println("Original : " + string(str))
fmt.Println("Title : " + string(title))
fmt.Println("To Title : " + string(totitle))
}
Output :
Original : this is a title!
Title : This Is A Title!
To Title : THIS IS A TITLE!
Advertisement
Something interesting
Tutorials
+11.3k Golang : Byte format example
+20k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+9.1k Golang : Get curl -I or head data from URL example
+5.8k Golang : List all packages and search for certain package
+46.5k Golang : Marshal and unmarshal json.RawMessage struct example
+14.5k How to automatically restart your crashed Golang server
+14.9k Golang : Basic authentication with .htpasswd file
+21.6k Golang : GORM create record or insert new record into database example
+48.5k Golang : Upload file from web browser to server
+34.1k Golang : Create x509 certificate, private and public keys
+9.7k Golang : Eroding and dilating image with OpenCV example