MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / pop_back_utf8_char

Function pop_back_utf8_char

common/console.cpp:336–350  ·  view source on GitHub ↗

Helper function to remove the last UTF-8 character from a string

Source from the content-addressed store, hash-verified

334
335 // Helper function to remove the last UTF-8 character from a string
336 static void pop_back_utf8_char(std::string & line) {
337 if (line.empty()) {
338 return;
339 }
340
341 size_t pos = line.length() - 1;
342
343 // Find the start of the last UTF-8 character (checking up to 4 bytes back)
344 for (size_t i = 0; i < 3 && pos > 0; ++i, --pos) {
345 if ((line[pos] & 0xC0) != 0x80) {
346 break; // Found the start of the character
347 }
348 }
349 line.erase(pos);
350 }
351
352 static bool readline_advanced(std::string & line, bool multiline_input) {
353 if (out != stdout) {

Callers 1

readline_advancedFunction · 0.70

Calls 2

lengthMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected