1 // Copyright 2022 Google LLC 2 // 3 // Use of this source code is governed by an MIT-style 4 // license that can be found in the LICENSE file or at 5 // https://opensource.org/licenses/MIT. 6 7 #ifndef THIRD_PARTY_UTF8_RANGE_UTF8_VALIDITY_H_ 8 #define THIRD_PARTY_UTF8_RANGE_UTF8_VALIDITY_H_ 9 10 #include <cstddef> 11 12 #include "absl/strings/string_view.h" 13 14 namespace utf8_range { 15 16 // Returns true if the sequence of characters is a valid UTF-8 sequence. 17 bool IsStructurallyValid(absl::string_view str); 18 19 // Returns the length in bytes of the prefix of str that is all 20 // structurally valid UTF-8. 21 size_t SpanStructurallyValid(absl::string_view str); 22 23 } // namespace utf8_range 24 25 #endif // THIRD_PARTY_UTF8_RANGE_UTF8_VALIDITY_H_ 26