Created
April 18, 2018 02:41
-
-
Save irrationalRock/ce307470c06ffaa8cb9572b33bd08001 to your computer and use it in GitHub Desktop.
BrotliIsMostlyUTF8(25.06)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BROTLI_BOOL BrotliIsMostlyUTF8( | |
const uint8_t* data, const size_t pos, const size_t mask, | |
const size_t length, const double min_fraction) { | |
size_t size_utf8 = 0; | |
size_t i = 0; | |
while (i < length) { | |
int symbol; | |
size_t bytes_read = | |
BrotliParseAsUTF8(&symbol, &data[(pos + i) & mask], length - i); | |
i += bytes_read; | |
if (symbol < 0x110000) size_utf8 += bytes_read; | |
} | |
return TO_BROTLI_BOOL(size_utf8 > min_fraction * (double)length); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment