]> Cypherpunks.ru repositories - gostls13.git/commitdiff
strings: document the use of simple case-folding in EqualFold
authorhopehook <hopehook.com@gmail.com>
Wed, 30 Mar 2022 07:47:57 +0000 (15:47 +0800)
committerEmmanuel Odeke <emmanuel@orijtech.com>
Sat, 2 Apr 2022 06:48:45 +0000 (06:48 +0000)
Fixes #52022

Change-Id: I077fc062dfd02f79eb83713490efbe0bdc783d8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/396616
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
src/strings/example_test.go
src/strings/strings.go

index 94aa167f90900c57be37a90d484455f88c7e5468..2a59512ceb9341903d4cb79b5658ca684079854a 100644 (file)
@@ -95,7 +95,12 @@ func ExampleCut() {
 
 func ExampleEqualFold() {
        fmt.Println(strings.EqualFold("Go", "go"))
-       // Output: true
+       fmt.Println(strings.EqualFold("AB", "ab")) // true because comparison uses simple case-folding
+       fmt.Println(strings.EqualFold("ß", "ss"))  // false because comparison does not use full case-folding
+       // Output:
+       // true
+       // true
+       // false
 }
 
 func ExampleFields() {
index ed3184b59c8fde380246fa229a7c9251d49f6cc4..74e505338e1e54480b6741234ac5331e4c2503ed 100644 (file)
@@ -1041,8 +1041,10 @@ func ReplaceAll(s, old, new string) string {
 }
 
 // EqualFold reports whether s and t, interpreted as UTF-8 strings,
-// are equal under Unicode case-folding, which is a more general
+// are equal under simple Unicode case-folding, which is a more general
 // form of case-insensitivity.
+//
+// EqualFold(s, t) is equivalent to Tolower(s) == Tolower(t).
 func EqualFold(s, t string) bool {
        for s != "" && t != "" {
                // Extract first rune from each string.