Golang bytes.EqualFold() function example
package bytes
EqualFold reports whether the given inputs, interpreted as UTF-8 strings, are equal under Unicode case-folding.
Golang bytes.EqualFold() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
slice1 := []byte("世界")
slice2 := []byte("xyz")
slice3 := []byte("世界")
fmt.Println(bytes.EqualFold(slice1, slice2))
fmt.Println(bytes.EqualFold(slice1, slice3))
fmt.Println(bytes.EqualFold(slice2,[]byte("XYZ"))) // big cap and small cap
}
Output :
false
true
true
Reference :
Advertisement
Something interesting
Tutorials
+5.8k Golang : List all packages and search for certain package
+31.1k Golang : Calculate percentage change of two values
+20.3k Swift : Convert (cast) Int to int32 or Uint32
+4.9k Javascript : How to get width and height of a div?
+8.3k Golang : Number guessing game with user input verification example
+13.5k Golang : How to get year, month and day?
+7.5k Golang : Create zip/ePub file without compression(use Store algorithm)
+12.3k Golang : How to display image file or expose CSS, JS files from localhost?
+15.3k Golang : Delete certain files in a directory
+18.5k Golang : Set, Get and List environment variables
+7.8k Golang : Example of how to detect which type of script a word belongs to
+6k Golang : Compound interest over time example