SofaBuffers C/C++ 0.12.0
API Documentation
Loading...
Searching...
No Matches
sofab::detail Namespace Reference

Functions

std::size_t utf8Prefix (std::string_view sv, std::size_t n) noexcept
 Length of the longest prefix of sv that is at most n bytes and does not end inside a UTF-8 character; sv is longer than n.
 

Function Documentation

◆ utf8Prefix()

std::size_t sofab::detail::utf8Prefix ( std::string_view  sv,
std::size_t  n 
)
inlinenoexcept

Length of the longest prefix of sv that is at most n bytes and does not end inside a UTF-8 character; sv is longer than n.

The over-long half of FixedString's assignment-time clamp, one copy for every capacity: the cut moves back while the first byte left out is a continuation byte (10xxxxxx), so a valid UTF-8 sv keeps a valid UTF-8 prefix. The common case – the value fits – stays inline in FixedString::assign, where a literal's length folds away.

Definition at line 269 of file sofab.hpp.

Here is the call graph for this function:
Here is the caller graph for this function: