1234567891011121314151617181920212223242526272829303132333435 |
- package util
- import "unicode/utf8"
- // StrLen utf8 string length
- func StrLen(s string) int {
- return utf8.RuneCountInString(s)
- }
- // StrMax verify string's max lenth
- func StrMax(s string, max int) bool {
- n := utf8.RuneCountInString(s)
- if n <= max {
- return true
- }
- return false
- }
- // StrMin verify string's min lenth
- func StrMin(s string, min int) bool {
- n := utf8.RuneCountInString(s)
- if n >= min {
- return true
- }
- return false
- }
- // StrRange verify string's Range lenth
- func StrRange(s string, min, max int) bool {
- n := utf8.RuneCountInString(s)
- if n <= max && n >= min {
- return true
- }
- return false
- }
|