Is there any difference between the ToUpper and the ToTitle function?
The ToUpper method is often used to convert a string to uppercase so that it can be used in a case-insensitive comparison. A better method to perform case-insensitive comparison is to call a string comparison method that has a StringComparison parameter whose value you set to StringComparison.
C++ String has got built-in toupper() function to convert the input String to Uppercase.
ToUpper converts all characters to uppercase characters. It causes a copy to be made of the VB.NET String, which is returned. Here We look at ToUpper and its behavior. This console program shows the result of ToUpper on the input String "abc123".
String. This method is used to returns a copy of the current string converted to uppercase. Syntax: public string ToUpper(); Return Type: Its return the string value, which is the uppercase equivalent of the given string.
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
I had the same problem. You want to use the strings.Title()
method not the strings.ToTitle()
method.
http://golang.org/pkg/strings/#Title
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With