Look up the canonical composition of (base + combining mark), or 0 if none.
| 5 | namespace { |
| 6 | // Look up the canonical composition of (base + combining mark), or 0 if none. |
| 7 | uint32_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 | |
| 26 | std::string utf8ComposeNfc(const std::string& in) { |