MCPcopy Index your code
hub / github.com/perkeep/perkeep / utf8StrLen

Function utf8StrLen

pkg/schema/schema.go:398–412  ·  view source on GitHub ↗

utf8StrLen returns how many prefix bytes of s are valid UTF-8.

(s string)

Source from the content-addressed store, hash-verified

396
397// utf8StrLen returns how many prefix bytes of s are valid UTF-8.
398func utf8StrLen(s string) int {
399 for i, r := range s {
400 for r == utf8.RuneError {
401 // The RuneError value can be an error
402 // sentinel value (if it's size 1) or the same
403 // value encoded properly. Decode it to see if
404 // it's the 1 byte sentinel value.
405 _, size := utf8.DecodeRuneInString(s[i:])
406 if size == 1 {
407 return i
408 }
409 }
410 }
411 return len(s)
412}
413
414func (ss *superset) SumPartsSize() (size uint64) {
415 for _, part := range ss.Parts {

Callers 2

mixedArrayFromStringFunction · 0.85
TestUtf8StrLenFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestUtf8StrLenFunction · 0.68