]> Cypherpunks repositories - gostls13.git/commitdiff
strings, bytes: deprecate Title
authorsmasher164 <aindurti@gmail.com>
Thu, 28 Oct 2021 21:08:22 +0000 (17:08 -0400)
committerIan Lance Taylor <iant@golang.org>
Fri, 5 Nov 2021 21:27:34 +0000 (21:27 +0000)
Title doesn't handle Unicode punctuation and language-specific
capitalization rules. Replace the BUG comment with a Deprecated
one, suggesting a more robust alternative, and allowing Title
to be exposed to tooling.

Fixes #48367.

Change-Id: I952f1f37cd35b587a95893fb022827bdd9ec7de9
Reviewed-on: https://go-review.googlesource.com/c/go/+/359485
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

src/bytes/bytes.go
src/strings/strings.go

index 9e6b68eaf4ea3e8145a350647dd1bc7e0f14b720..6fdaa49c7344921da2d1c987d714a61884935157 100644 (file)
@@ -746,7 +746,8 @@ func isSeparator(r rune) bool {
 // Title treats s as UTF-8-encoded bytes and returns a copy with all Unicode letters that begin
 // words mapped to their title case.
 //
-// BUG(rsc): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
+// Deprecated: The rule Title uses for word boundaries does not handle Unicode
+// punctuation properly. Use golang.org/x/text/cases instead.
 func Title(s []byte) []byte {
        // Use a closure here to remember state.
        // Hackish but effective. Depends on Map scanning in order and calling
index bc734048c3fc2223cf57b2bdf9f739d1dcb62e19..c5a29e95f6dd5ac7602e9544fc1c8ffdc73bc865 100644 (file)
@@ -706,7 +706,8 @@ func isSeparator(r rune) bool {
 // Title returns a copy of the string s with all Unicode letters that begin words
 // mapped to their Unicode title case.
 //
-// BUG(rsc): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
+// Deprecated: The rule Title uses for word boundaries does not handle Unicode
+// punctuation properly. Use golang.org/x/text/cases instead.
 func Title(s string) string {
        // Use a closure here to remember state.
        // Hackish but effective. Depends on Map scanning in order and calling