Changeset a65ccc4 in mainline for common/str.c
- Timestamp:
- 2025-04-17T15:24:13Z (5 days ago)
- Children:
- 61c91532
- Parents:
- fb75979 (diff), 1db4e2ae (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Wayne Thornton <wmthornton-dev@…> (2025-04-17 15:24:13)
- git-committer:
- GitHub <noreply@…> (2025-04-17 15:24:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/str.c
rfb75979 ra65ccc4 547 547 548 548 for (; n > 0 && b[0]; b++, n--) { 549 if (b[0] < ' ') { 550 /* C0 control codes */ 551 b[0] = replacement; 552 count++; 553 continue; 554 } 555 549 556 int cont = _continuation_bytes(b[0]); 550 557 if (__builtin_expect(cont, 0) == 0) … … 584 591 } 585 592 593 bool c1_control = (b[0] == 0b11000010 && b[1] < 0b10100000); 594 if (cont == 1 && c1_control) { 595 b[0] = replacement; 596 count++; 597 continue; 598 } 599 586 600 /* 0b1110!!!! 0b10!xxxxx 0b10xxxxxx */ 587 601 if (cont == 2 && !(b[0] & 0b00001111) && !(b[1] & 0b00100000)) { … … 619 633 } 620 634 635 /** Replaces any byte that's not part of a complete valid UTF-8 character 636 * encoding with a replacement byte. 637 * Also replaces C0 and C1 control codes. 638 */ 621 639 size_t str_sanitize(char *str, size_t n, uint8_t replacement) 622 640 {
Note:
See TracChangeset
for help on using the changeset viewer.