Add codePointToGlyph to convert codepoint into string
This commit is contained in:
parent
5e6f0abfd6
commit
fd442a3a2b
13
utils.go
13
utils.go
|
@ -2,9 +2,11 @@ package main // import "eriol.xyz/piken"
|
|||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
|
@ -84,3 +86,14 @@ func readCsvFile(filepath string) (records [][]string, err error) {
|
|||
return records, nil
|
||||
|
||||
}
|
||||
|
||||
// Convert an unicode codepoint into a string.
|
||||
func codePointToGlyph(codepoint string) (string, error) {
|
||||
|
||||
s, err := strconv.ParseInt(codepoint, 16, 32)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("%c", s), nil
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue