Golang unicode/utf16.Decode() function example
package unicode/utf16
Golang unicode/utf16.Decode() function usage example
package main
import (
"fmt"
"unicode/utf16"
)
func main() {
var rune_array []rune
rune_array = utf16.Decode([]uint16{0xdfff})
fmt.Println(rune_array)
rune_array = utf16.Decode([]uint16{'爱', 0xd800, 'a'})
fmt.Println(rune_array)
}
Output :
[65533]
[29233 65533 97]
Reference :
https://golang.org/pkg/unicode/utf16/#Decode
Advertisement
Something interesting
Tutorials
+8.2k Golang : Find relative luminance or color brightness
+19.8k Golang : Append content to a file
+8.1k Golang : Randomize letters from a string example
+12k Golang : Decompress zlib file example
+20.8k Golang : Convert date string to variants of time.Time type examples
+4.4k Golang : Valued expressions and functions example
+22.1k Golang : Repeat a character by multiple of x factor
+10.8k Golang : Natural string sorting example
+11.1k Golang : How to determine a prime number?
+13.9k Golang : Human readable time elapsed format such as 5 days ago
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+8.7k Golang : Find duplicate files with filepath.Walk