| 598 | namespace { |
| 599 | |
| 600 | absl::StatusOr<size_t> SubstringImpl(absl::string_view string, uint64_t start) { |
| 601 | size_t size_code_points = 0; |
| 602 | size_t size_code_units = 0; |
| 603 | while (!string.empty()) { |
| 604 | char32_t code_point; |
| 605 | size_t code_units; |
| 606 | std::tie(code_point, code_units) = cel::internal::Utf8Decode(string); |
| 607 | if (size_code_points == start) { |
| 608 | return size_code_units; |
| 609 | } |
| 610 | string.remove_prefix(code_units); |
| 611 | ++size_code_points; |
| 612 | size_code_units += code_units; |
| 613 | } |
| 614 | if (size_code_points == start) { |
| 615 | return size_code_units; |
| 616 | } |
| 617 | return absl::InvalidArgumentError( |
| 618 | "<string>.substring(<start>): <start> is greater than <string>.size()"); |
| 619 | } |
| 620 | |
| 621 | absl::StatusOr<absl::Cord> SubstringImpl(const absl::Cord& cord, |
| 622 | uint64_t start) { |
nothing calls this directly
no test coverage detected