Golang unicode.SimpleFold() function example
package unicode
SimpleFold returns the equivalent unicode in Upper case if input is lower case and vice-versa.
package main
import (
"fmt"
"unicode"
)
func main() {
sr := unicode.SimpleFold('\u212A')
fmt.Println(sr) // wrong way to print!
fmt.Printf("%+q\n", sr) // simpleFold will return K (Kelvin symbol)
src := unicode.SimpleFold('你')
fmt.Printf("%q\n", src) // simpleFold will return the same character 你
fmt.Printf("%+q\n", src) // simpleFold will return the unicode codepoint
sra := unicode.SimpleFold('A')
fmt.Printf("%+q\n", sra) // simpleFold will return the lower case 'a'
}
Output :
75
'K'
'你'
'\u4f60'
'a'
References :
Advertisement
Something interesting
Tutorials
+8.8k Golang : On lambda, anonymous, inline functions and function literals
+5.8k Golang : Markov chains to predict probability of next state example
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+7.5k Golang : Gorrila set route name and get the current route name
+10.5k Golang : Select region of interest with mouse click and crop from image
+8k Golang : What fmt.Println() can do and println() cannot do
+13.8k Golang : convert(cast) string to float value
+7k Golang : How to call function inside template with template.FuncMap
+11.5k CodeIgniter : Import Linkedin data
+7.9k Golang : Gomobile init produce "iphoneos" cannot be located error
+11.7k How to tell if a binary(executable) file or web application is built with Golang?
+11k Golang : Generate random elements without repetition or duplicate