You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
942 B
43 lines
942 B
package str
|
|
|
|
// IsBlank 是否空(空白)字符串.
|
|
func (ts *Str) IsBlank(str string) bool {
|
|
// Check length
|
|
if len(str) > 0 {
|
|
// Iterate string
|
|
for i := range str {
|
|
// Check about char different from whitespace
|
|
// 227为全角空格
|
|
if str[i] > 32 && str[i] != 227 {
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// IsNotBlank 是否非空(非空白)字符串.
|
|
func (ts *Str) IsNotBlank(str string) bool {
|
|
return !ts.IsBlank(str)
|
|
}
|
|
|
|
// IsEmpty 是否空字符串.
|
|
func (ts *Str) IsEmpty(str string) bool {
|
|
return len(str) == 0
|
|
}
|
|
|
|
// IsNotEmpty 是否非空字符串.
|
|
func (ts *Str) IsNotEmpty(str string) bool {
|
|
return !ts.IsEmpty(str)
|
|
}
|
|
|
|
// IsBlankOrEmpty 是否空白或空字符串.
|
|
func (ts *Str) IsBlankOrEmpty(str string) bool {
|
|
return ts.IsBlank(str) || ts.IsEmpty(str)
|
|
}
|
|
|
|
// IsNotBlankOrEmpty 是否非空白或非空字符串.
|
|
func (ts *Str) IsNotBlankOrEmpty(str string) bool {
|
|
return !ts.IsBlankOrEmpty(str)
|
|
}
|