Confusing ToUpper and ToTitle

后端 未结 5 1282
长发绾君心
长发绾君心 2021-01-01 16:18

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

5条回答
  •  时光说笑
    2021-01-01 16:54

    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

提交回复
热议问题