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
+22.1k Golang : Match strings by wildcard patterns with filepath.Match() function
+14.2k Elastic Search : Mapping date format and sort by date
+10.1k Golang : Edge detection with Sobel method
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+11.4k Golang : Concatenate (combine) buffer data example
+8.3k Useful methods to access blocked websites
+11.4k Golang : Delay or limit HTTP requests example
+9.2k nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
+8.1k Golang : Append and add item in slice
+9k Golang : Capture text return from exec function example
+12.7k Golang : Pass database connection to function called from another package and HTTP Handler