2023-10-11 01:15:23 +08:00
|
|
|
package strutil
|
|
|
|
|
2023-10-30 21:54:20 +08:00
|
|
|
import (
|
|
|
|
"unicode"
|
|
|
|
)
|
2023-10-11 01:15:23 +08:00
|
|
|
|
|
|
|
func containsBinary(str string) bool {
|
2023-11-17 16:26:03 +08:00
|
|
|
//buf := []byte(str)
|
2023-10-11 01:15:23 +08:00
|
|
|
//size := 0
|
|
|
|
//for start := 0; start < len(buf); start += size {
|
|
|
|
// var r rune
|
|
|
|
// if r, size = utf8.DecodeRune(buf[start:]); r == utf8.RuneError {
|
|
|
|
// return true
|
|
|
|
// }
|
|
|
|
//}
|
2023-10-30 21:54:20 +08:00
|
|
|
rs := []rune(str)
|
|
|
|
for _, r := range rs {
|
2023-11-17 16:26:03 +08:00
|
|
|
if !unicode.IsPrint(r) && !unicode.IsSpace(r) {
|
2023-10-30 21:54:20 +08:00
|
|
|
return true
|
|
|
|
}
|
2023-10-11 01:15:23 +08:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2023-11-17 16:26:03 +08:00
|
|
|
|
|
|
|
func isSameChar(str string) bool {
|
|
|
|
if len(str) <= 0 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
rs := []rune(str)
|
|
|
|
first := rs[0]
|
|
|
|
for _, r := range rs {
|
|
|
|
if r != first {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|