internal/bytealg/index_non_ascii_generic.go
raw| 1 | //go:build !amd64 && !arm64 |
| 2 | // +build !amd64,!arm64 |
| 3 | |
| 4 | package bytealg |
| 5 | |
| 6 | import "unicode/utf8" |
| 7 | |
| 8 | func IndexByteNonASCII(b []byte) int { |
| 9 | for i := 0; i < len(b); i++ { |
| 10 | if b[i]&utf8.RuneSelf != 0 { |
| 11 | return i |
| 12 | } |
| 13 | } |
| 14 | return -1 |
| 15 | } |
| 16 | |
| 17 | func IndexNonASCII(s string) int { |
| 18 | for i := 0; i < len(s); i++ { |
| 19 | if s[i]&utf8.RuneSelf != 0 { |
| 20 | return i |
| 21 | } |
| 22 | } |
| 23 | return -1 |
| 24 | } |