ascii/valid.go
raw| 1 | package ascii |
| 2 | |
| 3 | import "github.com/segmentio/asm/internal/unsafebytes" |
| 4 | |
| 5 | // Valid returns true if b contains only ASCII characters. |
| 6 | func Valid(b []byte) bool { |
| 7 | return ValidString(unsafebytes.String(b)) |
| 8 | } |
| 9 | |
| 10 | // ValidBytes returns true if b is an ASCII character. |
| 11 | func ValidByte(b byte) bool { |
| 12 | return b <= 0x7f |
| 13 | } |
| 14 | |
| 15 | // ValidBytes returns true if b is an ASCII character. |
| 16 | func ValidRune(r rune) bool { |
| 17 | return r <= 0x7f |
| 18 | } |