MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / utf8ComposePair

Function utf8ComposePair

lib/Utf8/Utf8.cpp:7–23  ·  view source on GitHub ↗

Look up the canonical composition of (base + combining mark), or 0 if none.

Source from the content-addressed store, hash-verified

5namespace {
6// Look up the canonical composition of (base + combining mark), or 0 if none.
7uint32_t utf8ComposePair(const uint32_t base, const uint32_t mark) {
8 if (base > 0xFFFF || mark > 0xFFFF) return 0;
9 int lo = 0;
10 int hi = kUtf8ComposeTableSize - 1;
11 while (lo <= hi) {
12 const int mid = (lo + hi) / 2;
13 const Utf8ComposeEntry& e = kUtf8ComposeTable[mid];
14 if (e.base < base || (e.base == base && e.mark < mark)) {
15 lo = mid + 1;
16 } else if (e.base > base || (e.base == base && e.mark > mark)) {
17 hi = mid - 1;
18 } else {
19 return e.composed;
20 }
21 }
22 return 0;
23}
24} // namespace
25
26std::string utf8ComposeNfc(const std::string& in) {

Callers 1

utf8ComposeNfcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected