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

Function firstCodepoint

lib/Epub/Epub/ParsedText.cpp:38–45  ·  view source on GitHub ↗

Returns the first rendered codepoint of a word (skipping leading soft hyphens).

Source from the content-addressed store, hash-verified

36
37// Returns the first rendered codepoint of a word (skipping leading soft hyphens).
38uint32_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.
48uint32_t lastCodepoint(const std::string& word) {

Callers 4

addWordMethod · 0.85
computeLineBreaksMethod · 0.85
extractLineMethod · 0.85

Calls 1

utf8NextCodepointFunction · 0.85

Tested by

no test coverage detected