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
+19.1k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+11.6k Golang : Display a text file line by line with line number example
+18.7k Unmarshal/Load CSV record into struct in Go
+11.1k Golang : Simple image viewer with Go-GTK
+10.4k Golang : Generate random integer or float number
+8.1k Golang : Append and add item in slice
+7.5k Golang : How to stop user from directly running an executable file?
+3.7k Golang : Switch Redis database redis.NewClient
+5.2k Golang : Print instead of building pyramids
+16.3k Golang :Trim white spaces from a string
+27.6k PHP : Convert(cast) string to bigInt
+17.7k How to enable MariaDB/MySQL logs ?