| 66 | |
| 67 | |
| 68 | std::string trim(const std::string& s) { |
| 69 | const std::string whitespace = " \n\r\t"; |
| 70 | size_t first = s.find_first_not_of(whitespace); |
| 71 | if (first == std::string::npos) |
| 72 | return ""; |
| 73 | size_t last = s.find_last_not_of(whitespace); |
| 74 | if (last == std::string::npos) |
| 75 | return ""; |
| 76 | return s.substr(first, last - first + 1); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | std::string truncate(const std::string& s, size_t maxCodepoints) { |