blob: be9786da623d168bc52d2d73bba9afc1b21cc333 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#ifndef THIRD_PARTY_UTF8_RANGE_UTF8_RANGE_H_
#define THIRD_PARTY_UTF8_RANGE_UTF8_RANGE_H_
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
// Returns 1 if the sequence of characters is a valid UTF-8 sequence, otherwise
// 0.
bool utf8_range_IsValid(const char* data, size_t len);
// Returns the length in bytes of the prefix of str that is all
// structurally valid UTF-8.
size_t utf8_range_ValidPrefix(const char* data, size_t len);
// Legacy API for backward compatibility
// Only needed for platforms without SSE4.1 (where range2-sse.c is not compiled)
#ifndef __SSE4_1__
int utf8_naive(const unsigned char* data, int len);
static inline int utf8_range2(const unsigned char* data, int len) {
return utf8_naive(data, len);
}
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // THIRD_PARTY_UTF8_RANGE_UTF8_RANGE_H_
|