Returns the first rendered codepoint of a word (skipping leading soft hyphens).
| 36 | |
| 37 | // Returns the first rendered codepoint of a word (skipping leading soft hyphens). |
| 38 | uint32_t firstCodepoint(const std::string& word) { |
| 39 | const auto* ptr = reinterpret_cast<const unsigned char*>(word.c_str()); |
| 40 | while (true) { |
| 41 | const uint32_t cp = utf8NextCodepoint(&ptr); |
| 42 | if (cp == 0) return 0; |
| 43 | if (cp != 0x00AD) return cp; // skip soft hyphens |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | // Returns the last codepoint of a word by scanning backward for the start of the last UTF-8 sequence. |
| 48 | uint32_t lastCodepoint(const std::string& word) { |
no test coverage detected