blob: 56bcfeae4f6002d8f0e52f55ccdd61257df017e9 (
plain)
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
33
34
35
36
37
|
#ifndef CODEPOINT_ITERATOR_UTILITY_H_
#define CODEPOINT_ITERATOR_UTILITY_H_
#include <cstdint>
namespace UTF8 {
namespace dtl {
enum class CodeUnitType : std::uint8_t {
CONTINUATION = 0b10000000,
LEADING = 0b01000000,
THREE = 0b00100000,
FOUR = 0b00010000
};
enum class CodePoint : std::uint8_t {
CONTINUATION = 0b00111111,
TWO = 0b00011111,
THREE = 0b00001111,
FOUR = 0b00000111
};
inline bool match(const std::uint8_t unit, const CodeUnitType type) {
return unit & static_cast<std::uint8_t>(type);
}
inline void write(char32_t& point,
const std::uint8_t unit,
const CodePoint mask,
const std::uint8_t offset) {
point += (unit & static_cast<std::uint8_t>(mask)) << offset;
}
}
}
#endif // CODEPOINT_ITERATOR_UTILITY_H_
|