mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-08 22:52:29 +08:00
feat: add IsPrintable
This commit is contained in:
@@ -58,8 +58,8 @@ func IsAllLower(str string) bool {
|
||||
return str != ""
|
||||
}
|
||||
|
||||
// IsASCII checks if string is ASCII char.
|
||||
// Play:
|
||||
// IsASCII checks if string is all ASCII char.
|
||||
// Play: todo
|
||||
func IsASCII(str string) bool {
|
||||
for i := 0; i < len(str); i++ {
|
||||
if str[i] > unicode.MaxASCII {
|
||||
@@ -69,6 +69,20 @@ func IsASCII(str string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsPrintable checks if string is all printable chars.
|
||||
// Play: todo
|
||||
func IsPrintable(str string) bool {
|
||||
for _, r := range str {
|
||||
if !unicode.IsPrint(r) {
|
||||
if r == '\n' || r == '\r' || r == '\t' || r == '`' {
|
||||
continue
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// ContainUpper check if the string contain at least one upper case letter A-Z.
|
||||
// Play: https://go.dev/play/p/CmWeBEk27-z
|
||||
func ContainUpper(str string) bool {
|
||||
|
||||
Reference in New Issue
Block a user