#include #include "strings.h" #include "print.h" using namespace std; void str_print(const char * str) { lprtf("%s\n", str_wrap(str).c_str()); } string str_wrap(const char * str) { string out; for (; *str != '\0'; str++) { if (str[0] == '\n') { if (str[1] == '\n') { out += "\n\n"; str++; } else { out += " "; } continue; } out += *str; } return out; } vector str_split(const string & src, const string & delim) { if (src.size() == 0) return {}; vector out; size_t start = 0; size_t end = src.find(delim); while (end != string::npos) { out.push_back(src.substr(start, end - start)); start = end + delim.length(); end = src.find(delim, start); } out.push_back(src.substr(start)); return out; } string str_lower(const string & input) { string out = input; transform(out.begin(), out.end(), out.begin(), [](unsigned char c){ return tolower(c); }); return out; } string str_title(const string & input) { if (input.size() == 0) return ""; string out = str_lower(input); out[0] = toupper(out[0]); return out; }