src
utf16.h
Go to the documentation of this file.
1 #ifndef _RE2C_IR_REGEXP_ENCODING_UTF16_UTF16_
2 #define _RE2C_IR_REGEXP_ENCODING_UTF16_UTF16_
3 
4 #include "src/util/c99_stdint.h"
5 
6 namespace re2c {
7 
8 class utf16
9 {
10 public:
11  typedef uint32_t rune;
12 
13  static const uint32_t MAX_1WORD_RUNE;
14  static const uint32_t MIN_LEAD_SURR;
15  static const uint32_t MIN_TRAIL_SURR;
16  static const uint32_t MAX_TRAIL_SURR;
17 
18  /* leading surrogate of UTF-16 symbol */
19  static inline uint32_t lead_surr(rune r);
20 
21  /* trailing surrogate of UTF-16 symbol */
22  static inline uint32_t trail_surr(rune r);
23 };
24 
25 inline uint32_t utf16::lead_surr(rune r)
26 {
27  return ((r - 0x10000u) / 0x400u) + MIN_LEAD_SURR;
28 }
29 
30 inline uint32_t utf16::trail_surr(rune r)
31 {
32  return ((r - 0x10000u) % 0x400u) + MIN_TRAIL_SURR;
33 }
34 
35 } // namespace re2c
36 
37 #endif // _RE2C_IR_REGEXP_ENCODING_UTF16_UTF16_
static uint32_t trail_surr(rune r)
Definition: utf16.h:30
uint32_t rune
Definition: utf16.h:11
static const uint32_t MIN_TRAIL_SURR
Definition: utf16.h:15
static const uint32_t MAX_TRAIL_SURR
Definition: utf16.h:16
static uint32_t lead_surr(rune r)
Definition: utf16.h:25
static const uint32_t MAX_1WORD_RUNE
Definition: utf16.h:13
Definition: bitmap.cc:10
static const uint32_t MIN_LEAD_SURR
Definition: utf16.h:14