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
+10.3k Golang : Detect number of faces or vehicles in a photo
+10.2k Golang : Find and replace data in all files recursively
+26.8k Golang : Find files by extension
+9.7k Golang : Sort and reverse sort a slice of floats
+25.6k Golang : convert rune to integer value
+10.6k Golang : Allow Cross-Origin Resource Sharing request
+9.4k Android Studio : Indicate progression with ProgressBar example
+41.4k Golang : Convert string to array/slice
+36k Golang : Get file last modified date and time
+8.9k Golang : GMail API create and send draft with simple upload attachment example
+13.9k Golang : How to determine if a year is leap year?