aboutsummaryrefslogtreecommitdiff
path: root/src/strings/strings.go
diff options
context:
space:
mode:
authorAndrew Todd <andrew.todd@wework.com>2019-07-27 16:20:49 -0700
committerRob Pike <r@golang.org>2019-07-30 02:52:57 +0000
commitfbb819ebc443518e9caea3c1b0d0f9e0efec2262 (patch)
treed153c5c6138aff5431f1bdd82b546604a53fda33 /src/strings/strings.go
parent01d137262a713b308c4308ed5b26636895e68d89 (diff)
downloadgo-fbb819ebc443518e9caea3c1b0d0f9e0efec2262.tar.xz
strings: clarify usage of Title and ToTitle
This is intended to help clear up confusion around the usage of the Title and ToTitle functions. It includes a link to define title case to distinguish it from upper case. It also includes an additional example for the ToTitle function to showcase the difference in behavior between it and the Title function. Fixes #33302 Change-Id: I44e62962fb04d0d22966a39eda3a2d16de7a2291 Reviewed-on: https://go-review.googlesource.com/c/go/+/187825 Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/strings/strings.go')
-rw-r--r--src/strings/strings.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/strings/strings.go b/src/strings/strings.go
index 7337481380..cee315ce9e 100644
--- a/src/strings/strings.go
+++ b/src/strings/strings.go
@@ -610,7 +610,8 @@ func ToLower(s string) string {
return Map(unicode.ToLower, s)
}
-// ToTitle returns a copy of the string s with all Unicode letters mapped to their title case.
+// ToTitle returns a copy of the string s with all Unicode letters mapped to
+// their Unicode title case.
func ToTitle(s string) string { return Map(unicode.ToTitle, s) }
// ToUpperSpecial returns a copy of the string s with all Unicode letters mapped to their
@@ -626,7 +627,7 @@ func ToLowerSpecial(c unicode.SpecialCase, s string) string {
}
// ToTitleSpecial returns a copy of the string s with all Unicode letters mapped to their
-// title case, giving priority to the special casing rules.
+// Unicode title case, giving priority to the special casing rules.
func ToTitleSpecial(c unicode.SpecialCase, s string) string {
return Map(c.ToTitle, s)
}
@@ -707,7 +708,7 @@ func isSeparator(r rune) bool {
}
// Title returns a copy of the string s with all Unicode letters that begin words
-// mapped to their title case.
+// mapped to their Unicode title case.
//
// BUG(rsc): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
func Title(s string) string {