MCPcopy Index your code
hub / github.com/google/codesearch / validUTF8

Function validUTF8

index/write.go:581–594  ·  view source on GitHub ↗

validUTF8 reports whether the byte pair can appear in a valid sequence of UTF-8-encoded code points.

(c1, c2 uint32)

Source from the content-addressed store, hash-verified

579// validUTF8 reports whether the byte pair can appear in a
580// valid sequence of UTF-8-encoded code points.
581func validUTF8(c1, c2 uint32) bool {
582 switch {
583 case c1 < 0x80:
584 // 1-byte, must be followed by 1-byte or first of multi-byte
585 return c2 < 0x80 || 0xc0 <= c2 && c2 < 0xf8
586 case c1 < 0xc0:
587 // continuation byte, can be followed by nearly anything
588 return c2 < 0xf8
589 case c1 < 0xf8:
590 // first of multi-byte, must be followed by continuation byte
591 return 0x80 <= c2 && c2 < 0xc0
592 }
593 return false
594}
595
596// sortPost sorts the postentry list.
597// The list is already sorted by fileid (bottom 32 bits)

Callers 1

AddMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…