std::string ucfirst(std::string source) { for(uint16_t i = 0; i < (uint16_t)source.length(); ++i) { if(source[i] != ' ') { source[i] = upchar(source[i]); break; } } return source; }
std::string ucwords(std::string source) { bool tmp = true; for(uint16_t i = 0; i < (uint16_t)source.length(); ++i) { if(source[i] == ' ') tmp = true; else if(tmp) { source[i] = upchar(source[i]); tmp = false; } } return source; }
std::string article(const std::string& name) { if (name.empty()) return name; switch (upchar(name[0])) { case 'A': case 'E': case 'I': case 'O': case 'U': return std::string("an ") + name; default: return std::string("a ") + name; } }
////////////////////////////////////////////////// // Upcase a 0-terminated string, but at most n chars. void upper(char *upstr, char *str, int n) { for (; *str && n; str++, upstr++, n--) *upstr = upchar(*str); if (n) *upstr = '\0'; }
////////////////////////////////////////////////// // Upcase a 0-terminated string. void upper(char *upstr, char *str) { for (; *str; str++, upstr++) *upstr = upchar(*str); *upstr = '\0'; }