validUTF8 reports whether the byte pair can appear in a valid sequence of UTF-8-encoded code points.
(c1, c2 uint32)
| 579 | // validUTF8 reports whether the byte pair can appear in a |
| 580 | // valid sequence of UTF-8-encoded code points. |
| 581 | func 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) |
no outgoing calls
no test coverage detected
searching dependent graphs…