+FilterEmoji

This commit is contained in:
gazebo
2019-10-16 16:37:59 +08:00
parent 444b0583d0
commit ae275c8645
2 changed files with 20 additions and 4 deletions

View File

@@ -225,6 +225,22 @@ func FilterMb4(content string) string {
return newContent.String()
}
// 是否是修饰符比如控制EMOJI的颜色控制符ZWJ
func IsDecorateRune(value rune) bool {
return value == 0xFE0F || value == 0xFE0E || value == 0x200D
}
func FilterEmoji(content string) string {
newContent := &strings.Builder{}
for _, value := range []rune(content) {
size := utf8.RuneLen(value)
if size >= 1 && size <= 3 && !(value >= 0x2300 && value < 0x32A0 || value >= 0x1F000 && value < 0x1F9F0) && !IsDecorateRune(value) {
newContent.WriteRune(value)
}
}
return newContent.String()
}
func TrimBlankChar(str string) string {
return strings.Trim(str, "\n\r\t ")
}