1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 15:12:26 +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

@@ -45,6 +45,7 @@ import (
- [Unwrap](#Unwrap)
- [SplitWords](#SplitWords)
- [WordCount](#WordCount)
- [RemoveNonPrintable](#RemoveNonPrintable)
<div STYLE="page-break-after: always;"></div>
@@ -937,4 +938,35 @@ func main() {
// 0
// 0
}
```
### <span id="RemoveNonPrintable">RemoveNonPrintable</span>
<p>Remove non-printable characters from a string.</p>
<b>Signature:</b>
```go
func RemoveNonPrintable(str string) string
```
<b>Example:</b>
```go
import (
"fmt"
"github.com/duke-git/lancet/v2/strutil"
)
func main() {
result1 := strutil.RemoveNonPrintable("hello\u00a0 \u200bworld\n")
result2 := strutil.RemoveNonPrintable("你好😄")
fmt.Println(result1)
fmt.Println(result2)
// Output:
// hello world
// 你好😄
}
```

View File

@@ -45,6 +45,7 @@ import (
- [Unwrap](#Unwrap)
- [SplitWords](#SplitWords)
- [WordCount](#WordCount)
- [RemoveNonPrintable](#RemoveNonPrintable)
<div STYLE="page-break-after: always;"></div>
@@ -936,4 +937,35 @@ func main() {
// 0
// 0
}
```
### <span id="RemoveNonPrintable">RemoveNonPrintable</span>
<p>删除字符串中不可打印的字符。</p>
<b>函数签名:</b>
```go
func RemoveNonPrintable(str string) string
```
<b>示例:</b>
```go
import (
"fmt"
"github.com/duke-git/lancet/v2/strutil"
)
func main() {
result1 := strutil.RemoveNonPrintable("hello\u00a0 \u200bworld\n")
result2 := strutil.RemoveNonPrintable("你好😄")
fmt.Println(result1)
fmt.Println(result2)
// Output:
// hello world
// 你好😄
}
```