1
0
mirror of https://github.com/fumiama/emozi.git synced 2026-06-26 23:10:26 +08:00

feat(lookup): export EmptyMark

This commit is contained in:
源文雨
2024-02-22 15:59:48 +09:00
parent 9d52013573
commit 5c526dcadb
5 changed files with 445 additions and 444 deletions

View File

@@ -6,7 +6,8 @@ import (
"strings"
)
const = '🈳'
// EmptyMark 代表 "空" 的颜文字
const EmptyMark = '🈳'
// LookupChar 查一个汉字 (可能是多音字)
func (c *Coder) LookupChar(ch rune) (explains []string, err error) {
@@ -50,7 +51,7 @@ func (c *Coder) GetCharByID(id int64) (w, r rune, p, f, desc string, err error)
func 随机正查(m [][]string, isRandom bool, i uint8) string {
lst := m[i]
if len(lst) == 0 {
return string()
return string(EmptyMark)
}
if len(lst) == 1 || !isRandom {
return lst[0]
@@ -81,7 +82,7 @@ func (c *Coder) 部首(r rune) string {
c.mu.Lock()
defer c.mu.Unlock()
err := c.db.Find(部首表名, x, "WHERE R="+strconv.Itoa(int(r)))
if err == nil && len(x.E) > 0 && x.E != string() {
if err == nil && len(x.E) > 0 && x.E != string(EmptyMark) {
c.部首缓存[r] = x.E
return x.E
}
@@ -89,8 +90,8 @@ func (c *Coder) 部首(r rune) string {
c.部首缓存[r] = e
return e
}
c.部首缓存[r] = string()
return string()
c.部首缓存[r] = string(EmptyMark)
return string(EmptyMark)
}
func 二阶逆查[E ~uint8](lowm map[rune][]string, m map[string]E, s string) (enum E, n int) {