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
+33.6k Golang : How to check if slice or array is empty?
+39.2k Golang : How to read CSV file
+11.5k Golang : Generate DSA private, public key and PEM files example
+10.8k PHP : Convert(cast) bigInt to string
+6k Javascript : Get operating system and browser information
+10.6k Golang : ISO8601 Duration Parser example
+7.9k Golang Hello World Example
+30k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+7.8k Golang : Regular Expression find string example
+6.1k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+22.2k Golang : Securing password with salt