utf8_util.h 904 B

1234567891011121314151617181920212223242526272829303132
  1. /* Copyright 2013 Google Inc. All Rights Reserved.
  2. Distributed under MIT license.
  3. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
  4. */
  5. /* Heuristics for deciding about the UTF8-ness of strings. */
  6. #ifndef BROTLI_ENC_UTF8_UTIL_H_
  7. #define BROTLI_ENC_UTF8_UTIL_H_
  8. #include "../common/platform.h"
  9. #include <brotli/types.h>
  10. #if defined(__cplusplus) || defined(c_plusplus)
  11. extern "C" {
  12. #endif
  13. static const double kMinUTF8Ratio = 0.75;
  14. /* Returns 1 if at least min_fraction of the bytes between pos and
  15. pos + length in the (data, mask) ring-buffer is UTF8-encoded, otherwise
  16. returns 0. */
  17. BROTLI_INTERNAL BROTLI_BOOL BrotliIsMostlyUTF8(
  18. const uint8_t* data, const size_t pos, const size_t mask,
  19. const size_t length, const double min_fraction);
  20. #if defined(__cplusplus) || defined(c_plusplus)
  21. } /* extern "C" */
  22. #endif
  23. #endif /* BROTLI_ENC_UTF8_UTIL_H_ */