- [#] simplify FormatEmoji() algorithm
This commit is contained in:
parent
0cd471dd6d
commit
e2dfb621f2
8
emoji.go
8
emoji.go
@ -1,7 +1,7 @@
|
|||||||
package openwechat
|
package openwechat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"html"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -294,13 +294,11 @@ func FormatEmoji(text string) string {
|
|||||||
}
|
}
|
||||||
value := item[0]
|
value := item[0]
|
||||||
emojiCodeStr := item[1]
|
emojiCodeStr := item[1]
|
||||||
emojiCode, err := strconv.ParseInt(emojiCodeStr, 16, 64)
|
emojiCode, err := strconv.ParseInt(emojiCodeStr, 16, 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
text = strings.Replace(text, value, fmt.Sprintf("%c", emojiCode), -1)
|
||||||
emojiStr := html.UnescapeString("&#" + strconv.FormatInt(emojiCode, 10) + ";")
|
|
||||||
text = strings.Replace(text, value, emojiStr, -1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user