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
+17.4k Golang : Check if IP address is version 4 or 6
+18.4k Golang : How to remove certain lines from a file
+14.3k Golang : Recombine chunked files example
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+17.6k Golang : delete and modify XML file content
+27.2k Golang : Find files by name - cross platform example
+14.5k Golang : How to check if your program is running in a terminal
+29.5k Golang : Saving(serializing) and reading file with GOB
+9.6k Golang : Validate IPv6 example
+9.9k Golang : Translate language with language package example
+6.4k Golang : Break string into a slice of characters example
+4.6k MariaDB/MySQL : How to get version information