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
+10.9k Golang : Create Temporary File
+8.7k Golang : How to join strings?
+14.6k Golang : Convert(cast) int to float example
+8.4k Golang : How to check if input string is a word?
+8.2k Golang : Metaprogramming example of wrapping a function
+26.9k Golang : Force your program to run with root permissions
+10.6k Golang : Bubble sort example
+5.3k Golang : Pad file extension automagically
+5.3k Golang : Generate Interleaved 2 inch by 5 inch barcode
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+10.6k Golang : Simple File Server