| 163 | } |
| 164 | |
| 165 | size_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 |
| 176 | void utf8TruncateChars(std::string& str, const size_t numChars) { |
no test coverage detected