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
+4k Golang : Convert lines of string into list for delete and insert operation
+21.1k Generate checksum for a file in Go
+3.7k MariaDB/MySQL : How to get version information
+16.2k Golang : [json: cannot unmarshal object into Go value of type]
+5.2k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+8k Golang : Detect number of active displays and the display's resolution
+8.9k Golang : Use regular expression to get all upper case or lower case characters example
+14k Golang : How do I get the local IP (non-loopback) address ?
+7.6k Golang : Gonum standard normal random numbers example
+5.8k Golang : Calculate BMI and risk category
+7.8k Golang : How to extract video or image files from html source code
+5.5k Golang : How to validate ISBN?