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