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
+9.7k Random number generation with crypto/rand in Go
+15.2k Golang : Save(pipe) HTTP response into a file
+40.1k Golang : UDP client server read write example
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+21.1k Golang : Convert(cast) string to rune and back to string example
+28.5k Golang : Change a file last modified date and time
+20.9k Golang : Convert PNG transparent background image to JPG or JPEG image
+10.1k Golang : How to tokenize source code with text/scanner package?
+5.6k Golang : Shortening import identifier
+5.6k Javascript : How to refresh page with JQuery ?
+11.6k Golang : Simple file scaning and remove virus example
+37.5k Upload multiple files with Go