MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / runeBoundary

Function runeBoundary

internal/mailparse/parse.go:95–100  ·  view source on GitHub ↗

runeBoundary returns the largest index <= n that doesn't split a UTF-8 rune, so truncating at it never yields an invalid encoding.

(s string, n int)

Source from the content-addressed store, hash-verified

93// runeBoundary returns the largest index <= n that doesn't split a UTF-8 rune,
94// so truncating at it never yields an invalid encoding.
95func runeBoundary(s string, n int) int {
96 for n > 0 && !utf8RuneStart(s[n]) {
97 n--
98 }
99 return n
100}
101
102func utf8RuneStart(b byte) bool { return b&0xC0 != 0x80 }
103

Callers 1

ParseFunction · 0.85

Calls 1

utf8RuneStartFunction · 0.85

Tested by

no test coverage detected