Golang unicode/utf16.EncodeRune() function example
package unicode/utf16
Golang unicode/utf16.EncodeRune() function usage example.
package main
import (
"fmt"
"unicode/utf16"
)
func main() {
//r1 := '\u6C34'
//r2 := '水'
r1, r2 := utf16.EncodeRune('水')
fmt.Printf("u+%x u+%x \n", r1, r2)
// find surrogate for G clef symbol
r3, r4 := utf16.EncodeRune('\U0001D11E')
fmt.Printf("G clef surrogate runes are : u+%x u+%x \n", r3, r4)
}
Sample output :
u+fffd u+fffd
G clef surrogate runes are : u+d834 u+dd1e
Reference :
Advertisement
Something interesting
Tutorials
+17k Golang : XML to JSON example
+21.3k Golang : Create and resolve(read) symbolic links
+12.7k Golang : zlib compress file example
+6.5k Golang : Map within a map example
+7.8k Golang : Reverse a string with unicode
+39k Golang : How to iterate over a []string(array)
+10k Golang : Setting variable value with ldflags
+8.7k Golang : How to join strings?
+7.5k Golang : Handling Yes No Quit query input
+15.6k Golang : Force download file example
+12.3k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+10.6k Golang : Simple File Server