MCPcopy Create free account
hub / github.com/apache/brpc / ReadUnicodeCharacter

Function ReadUnicodeCharacter

src/butil/strings/utf_string_conversion_utils.cc:13–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11// ReadUnicodeCharacter --------------------------------------------------------
12
13bool ReadUnicodeCharacter(const char* src,
14 int32_t src_len,
15 int32_t* char_index,
16 uint32_t* code_point_out) {
17 // U8_NEXT expects to be able to use -1 to signal an error, so we must
18 // use a signed type for code_point. But this function returns false
19 // on error anyway, so code_point_out is unsigned.
20 int32_t code_point;
21 CBU8_NEXT(src, *char_index, src_len, code_point);
22 *code_point_out = static_cast<uint32_t>(code_point);
23
24 // The ICU macro above moves to the next char, we want to point to the last
25 // char consumed.
26 (*char_index)--;
27
28 // Validate the decoded value.
29 return IsValidCodepoint(code_point);
30}
31
32bool ReadUnicodeCharacter(const char16* src,
33 int32_t src_len,

Callers 2

ConvertUnicodeFunction · 0.85
ConvertUnicodeFunction · 0.85

Calls 1

IsValidCodepointFunction · 0.85

Tested by

no test coverage detected