TrimBlankChar添加对于隐藏字符的过滤
This commit is contained in:
@@ -242,7 +242,7 @@ func FilterEmoji(content string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TrimBlankChar(str string) string {
|
func TrimBlankChar(str string) string {
|
||||||
return strings.Trim(str, "\n\r\t ")
|
return strings.Trim(str, "\u202C\n\r\t ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func RemoveGeneralMapKeys(obj map[string]interface{}, keys ...string) map[string]interface{} {
|
func RemoveGeneralMapKeys(obj map[string]interface{}, keys ...string) map[string]interface{} {
|
||||||
|
|||||||
@@ -191,12 +191,23 @@ func TestRemoveGeneralMapKeys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTrimBlanChar(t *testing.T) {
|
func TestTrimBlanChar(t *testing.T) {
|
||||||
str := `
|
for _, strList := range [][]string{
|
||||||
大小21
|
[]string{
|
||||||
|
"大小21",
|
||||||
`
|
`
|
||||||
if TrimBlankChar(str) != "大小21" {
|
大小21
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
[]string{
|
||||||
|
"13518183468",
|
||||||
|
"13518183468", // 末尾有一个隐藏字符
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
t.Logf("%d,%d", len(strList[0]), len(strList[1]))
|
||||||
|
if TrimBlankChar(strList[1]) != strList[0] {
|
||||||
t.Fatal("TrimBlanChar doesn't work")
|
t.Fatal("TrimBlanChar doesn't work")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLimitUTF8StringLen(t *testing.T) {
|
func TestLimitUTF8StringLen(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user