MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ next_codepoint_offset()

MAYAFLUX_API size_t MayaFlux::Portal::Text::next_codepoint_offset ( std::string_view  text,
size_t  byte_offset 
)

Byte offset of the codepoint boundary after byte_offset.

Steps forward exactly one codepoint using the same utf8proc decode lay_out() uses, so malformed sequences are skipped identically rather than by a separate continuation-byte mask. Returns text.size() if already at or past the end.

Parameters
textUTF-8 encoded string.
byte_offsetCurrent byte offset, must be a codepoint boundary.
Returns
Byte offset of the next codepoint boundary.

Definition at line 183 of file TypeSetter.cpp.

184{
185 if (byte_offset >= text.size()) {
186 return text.size();
187 }
188
189 const auto* bytes = reinterpret_cast<const utf8proc_uint8_t*>(text.data());
190 const auto remaining = static_cast<utf8proc_ssize_t>(text.size() - byte_offset);
191
192 utf8proc_int32_t codepoint = 0;
193 const utf8proc_ssize_t n = utf8proc_iterate(bytes + byte_offset, remaining, &codepoint);
194
195 return byte_offset + static_cast<size_t>(n > 0 ? n : 1);
196}

Referenced by erase(), index_at(), and move().

+ Here is the caller graph for this function: