1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 14:42:27 +08:00

feat: add RemoveNonPrintable

This commit is contained in:
dudaodong
2023-03-30 14:52:32 +08:00
parent e56a8a1ef5
commit 217350042b
5 changed files with 95 additions and 0 deletions

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
}