- FilterMb4 added.

This commit is contained in:
gazebo
2018-07-17 22:14:52 +08:00
parent 378d39eb29
commit c787714293
2 changed files with 38 additions and 0 deletions

View File

@@ -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()
}