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
+9.1k Golang : Handle sub domain with Gin
+19.6k Golang : Get current URL example
+11.1k Golang : Simple image viewer with Go-GTK
+13.6k Android Studio : Password input and reveal password example
+14.3k Golang : How to shuffle elements in array or slice?
+16.3k Golang :Trim white spaces from a string
+8.3k Golang : Count leading or ending zeros(any item of interest) example
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+7.9k Golang : Grayscale Image
+7.2k Ubuntu : connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
+19.2k Golang : Populate dropdown with html/template example
+21.2k Golang : How to force compile or remove object files first before rebuild?