Files
wehub-resource-sync 48b3ccf279
Test / test (windows-latest) (push) Waiting to run
gitleaks / gitleaks (push) Has been skipped
Test / test (ubuntu-latest) (push) Failing after 0s
chore: import upstream snapshot with attribution
2026-07-13 12:12:29 +08:00

35 lines
683 B
Go

package codec
var printableASCII [256]bool
func init() {
for b := 0; b < len(printableASCII); b++ {
if '\x08' < b && b < '\x7f' {
printableASCII[b] = true
}
}
}
// isPrintableASCII returns true if all bytes are printable ASCII
func isPrintableASCII(b []byte) bool {
for _, c := range b {
if !printableASCII[c] {
return false
}
}
return true
}
// hasByte can be used to check if a string has at least one of the provided
// bytes. Note: make sure byteset is long enough to handle the largest byte in
// the string.
func hasByte(data string, byteset []bool) bool {
for i := 0; i < len(data); i++ {
if byteset[data[i]] {
return true
}
}
return false
}