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.3k Golang : Generate random Chinese, Japanese, Korean and other runes
+6.9k Golang : How to solve "too many .rsrc sections" error?
+5.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+4.8k Golang : A program that contain another program and executes it during run-time
+15.2k Golang : Get timezone offset from date or timestamp
+24.1k Golang : Upload to S3 with official aws-sdk-go package
+30.4k Golang : How to redirect to new page with net/http?
+33.6k Golang : How to check if slice or array is empty?
+7.4k Golang : Check to see if *File is a file or directory
+21.6k Golang : GORM create record or insert new record into database example
+8.5k Linux/Unix : fatal: the Postfix mail system is already running
+9.1k Golang : Intercept and compare HTTP response code example