Confusing ToUpper and ToTitle

Issue

Is there any difference between the ToUpper and the ToTitle function?

Solution

See this example on the difference of titlecase/uppercase:

package main

import (
    "fmt"
    "strings"
)

func main() {
    str := "dz"
    fmt.Println(strings.ToTitle(str))
    fmt.Println(strings.ToUpper(str))
}

(Note “dz” here is a single character, not a “d” followed by a “z”: dz vs dz)

http://play.golang.org/p/xpDPLqKM9C

Answered By – topskip

Answer Checked By – Willingham (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.