- FilterMb4 added.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"github.com/satori/go.uuid"
|
||||
@@ -147,3 +148,15 @@ func SendFakeRequest(method, url, body, contentType string) (*http.Response, err
|
||||
client := &http.Client{}
|
||||
return client.Do(request)
|
||||
}
|
||||
|
||||
// 过滤 utf8mb4(比如emoji表情)
|
||||
func FilterMb4(content string) string {
|
||||
newContent := &strings.Builder{}
|
||||
for _, value := range content {
|
||||
size := utf8.RuneLen(value)
|
||||
if size >= 1 && size <= 3 {
|
||||
newContent.WriteRune(value)
|
||||
}
|
||||
}
|
||||
return newContent.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user