feat: add RemoveNonPrintable

This commit is contained in:
dudaodong committed 2023-03-30 14:52:32 +08:00
1 parent e56a8a1ef5
commit 217350042b
5 files changed
+95

No files matched your search

+13
View File
@@ -360,3 +360,16 @@ func WordCount(s string) int {
return count
}
// RemoveNonPrintable remove non-printable characters from a string.
// Play: todo
func RemoveNonPrintable(str string) string {
result := strings.Map(func(r rune) rune {
if unicode.IsPrint(r) {
return r
}
return -1
}, str)
return result
}