MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetIterAtByte

Method GetIterAtByte

src/core/utf8.cpp:83–92  ·  view source on GitHub ↗

* Create iterator pointing at codepoint, which occupies the byte position "offset". * "offset" does not need to point at the first byte of the UTF-8 sequence, * the iterator will still address the correct position of the first byte. * @param offset Byte offset into view. * @return Iterator pointing at start of codepoint, of which "offset" is part of. */

Source from the content-addressed store, hash-verified

81 * @return Iterator pointing at start of codepoint, of which "offset" is part of.
82 */
83Utf8View::iterator Utf8View::GetIterAtByte(size_t offset) const
84{
85 assert(offset <= this->src.size());
86 if (offset >= this->src.size()) return this->end();
87
88 /* Sanitize iterator to point to the start of a codepoint */
89 auto it = iterator(this->src, offset + 1);
90 --it;
91 return it;
92}

Callers 4

GetCharPositionMethod · 0.80
DeleteCharMethod · 0.80
SetCurPositionMethod · 0.80
utf8.cppFile · 0.80

Calls 3

endMethod · 0.95
iteratorClass · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected