From 7aed6dd7e18e2ad3ac0f4eb692188ed7a90b778b Mon Sep 17 00:00:00 2001 From: smasher164 Date: Thu, 28 Oct 2021 17:08:22 -0400 Subject: [PATCH] strings, bytes: deprecate Title 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 Trust: Cherry Mui --- src/bytes/bytes.go | 3 ++- src/strings/strings.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index 9e6b68eaf4..6fdaa49c73 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -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 diff --git a/src/strings/strings.go b/src/strings/strings.go index bc734048c3..c5a29e95f6 100644 --- a/src/strings/strings.go +++ b/src/strings/strings.go @@ -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 -- 2.48.1