| 118 | |
| 119 | |
| 120 | std::string ellipsize(const std::string& s, size_t maxCodepoints) { |
| 121 | if (maxCodepoints == 0) |
| 122 | return ""; |
| 123 | std::string s2 = truncate(s, maxCodepoints); |
| 124 | if (s2 == s) |
| 125 | return s; |
| 126 | // If string was truncated, back up a codepoint and add a Unicode ellipses character |
| 127 | size_t pos = UTF8PrevCodepoint(s2, s2.size()); |
| 128 | return s2.substr(0, pos) + "…"; |
| 129 | } |
| 130 | |
| 131 | |
| 132 | std::string ellipsizePrefix(const std::string& s, size_t maxCodepoints) { |
no test coverage detected