utf8_validity.h 698 B

1234567891011121314151617181920212223
  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. #ifndef THIRD_PARTY_UTF8_RANGE_UTF8_VALIDITY_H_
  7. #define THIRD_PARTY_UTF8_RANGE_UTF8_VALIDITY_H_
  8. #include "y_absl/strings/string_view.h"
  9. namespace utf8_range {
  10. // Returns true if the sequence of characters is a valid UTF-8 sequence.
  11. bool IsStructurallyValid(y_absl::string_view str);
  12. // Returns the length in bytes of the prefix of str that is all
  13. // structurally valid UTF-8.
  14. size_t SpanStructurallyValid(y_absl::string_view str);
  15. } // namespace utf8_range
  16. #endif // THIRD_PARTY_UTF8_RANGE_UTF8_VALIDITY_H_