utf8_util.h revision 26fa459c
126fa459cSmrg/* Copyright 2013 Google Inc. All Rights Reserved. 226fa459cSmrg 326fa459cSmrg Distributed under MIT license. 426fa459cSmrg See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 526fa459cSmrg*/ 626fa459cSmrg 726fa459cSmrg/* Heuristics for deciding about the UTF8-ness of strings. */ 826fa459cSmrg 926fa459cSmrg#ifndef BROTLI_ENC_UTF8_UTIL_H_ 1026fa459cSmrg#define BROTLI_ENC_UTF8_UTIL_H_ 1126fa459cSmrg 1226fa459cSmrg#include "../common/platform.h" 1326fa459cSmrg#include <brotli/types.h> 1426fa459cSmrg 1526fa459cSmrg#if defined(__cplusplus) || defined(c_plusplus) 1626fa459cSmrgextern "C" { 1726fa459cSmrg#endif 1826fa459cSmrg 1926fa459cSmrgstatic const double kMinUTF8Ratio = 0.75; 2026fa459cSmrg 2126fa459cSmrg/* Returns 1 if at least min_fraction of the bytes between pos and 2226fa459cSmrg pos + length in the (data, mask) ring-buffer is UTF8-encoded, otherwise 2326fa459cSmrg returns 0. */ 2426fa459cSmrgBROTLI_INTERNAL BROTLI_BOOL BrotliIsMostlyUTF8( 2526fa459cSmrg const uint8_t* data, const size_t pos, const size_t mask, 2626fa459cSmrg const size_t length, const double min_fraction); 2726fa459cSmrg 2826fa459cSmrg#if defined(__cplusplus) || defined(c_plusplus) 2926fa459cSmrg} /* extern "C" */ 3026fa459cSmrg#endif 3126fa459cSmrg 3226fa459cSmrg#endif /* BROTLI_ENC_UTF8_UTIL_H_ */ 33