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
+25.5k Golang : Generate MD5 checksum of a file
+8.2k Golang : Add build version and other information in executables
+22.2k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+7.5k Golang : Dealing with struct's private part
+18.3k Golang : Get path name to current directory or folder
+4.6k Linux : sudo yum updates not working
+6.8k Golang : Find the longest line of text example
+9.2k Golang : How to check if a string with spaces in between is numeric?
+5.6k PHP : Fix Call to undefined function curl_init() error
+48.5k Golang : Upload file from web browser to server
+7.4k Android Studio : How to detect camera, activate and capture example
+12.2k Golang : Split strings into command line arguments