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

Function utf8RemoveLastChar

lib/Utf8/Utf8.cpp:165–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165size_t utf8RemoveLastChar(std::string& str) {
166 if (str.empty()) return 0;
167 size_t pos = str.size() - 1;
168 while (pos > 0 && (static_cast<unsigned char>(str[pos]) & 0xC0) == 0x80) {
169 --pos;
170 }
171 str.resize(pos);
172 return pos;
173}
174
175// Truncate string by removing N UTF-8 characters from the end
176void utf8TruncateChars(std::string& str, const size_t numChars) {

Callers 2

utf8TruncateCharsFunction · 0.85
truncatedTextMethod · 0.85

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected