Golang bytes.ToLowerSpecial() function example
package bytes
ToLowerSpecial returns a copy of the byte input slice with all Unicode letters mapped to their lower case, giving priority to the special casing rules. (See http://golang.org/pkg/unicode/#SpecialCase )
Golang bytes.ToLowerSpecial() function usage example
package main
import (
"fmt"
"bytes"
"unicode"
)
func main() {
str := []byte("ŞĞÜÖIİ")
tolower := bytes.ToLowerSpecial(unicode.AzeriCase, str)
fmt.Println(string(str))
fmt.Println(string(tolower))
}
Output :
ŞĞÜÖIİ
şğüöıi
To detect special case from the environment, try this function
var specialCase unicode.SpecialCase
func init() {
for _, env := range []string{"LC_ALL", "LC_CTYPE", "LANG"} {
locale := os.Getenv(env)
if strings.HasPrefix("tr_", locale) {
specialCase = unicode.TurkishCase
break
}
if strings.HasPrefix("az_", locale) {
specialCase = unicode.AzeriCase
break
}
}
}
Reference :
http://golang.org/pkg/unicode/#SpecialCase
Advertisement
Something interesting
Tutorials
+27.7k PHP : Count number of JSON items/objects
+41.2k Golang : How to count duplicate items in slice/array?
+15.9k Golang : Update database with GORM example
+6.4k CodeIgniter : form input set_value cause " to become & quot
+36.3k Golang : Convert(cast) int64 to string
+9.1k Golang : Simple histogram example
+6.7k Golang : Skip or discard items of non-interest when iterating example
+30.4k Golang : How to verify uploaded file is image or allowed file types
+5.9k Unix/Linux : How to open tar.gz file ?
+5.2k Golang : The Tao of importing package
+7.5k Golang : Create zip/ePub file without compression(use Store algorithm)
+12k Golang : Decompress zlib file example