如何在golang中将unicode(ex:\ u2713)代码转换为符文(ex:✓)?

code:

var checkMark = "\u2713"  // stand for rune "✓"

and how to convert unicode "\u2713" to the rune "✓" and print it ? Is anyone can help me, Thanks a lot very much.

As if you have a string like "\u2713\u2715".

See in playground https://play.golang.org/p/AxpnCzNEOfr

package main

import (
    "fmt"
    "unicode/utf8"
)

func main() {
    src := "\u2713\u2715"
    r, _ := utf8.DecodeRuneInString(src)
    fmt.Printf("the first rune of src is %v, code: %d",string(r), r)
}

// Output
// the first rune of src is ✓, code: 10003

More sample about utf8.DecodeRuneInString can find from answer https://stackoverflow.com/a/54274978/10737552

The string literal "\u2713" is a string containing the single rune . No conversion is required.

Use the fmt package to print strings: fmt.Println("\u2713")

To get the as a rune, use the rune literal '\u2713'

Run it on the playground