Add overload of wcstringutil::trim that automatically trims whitespace

This commit is contained in:
Mahmoud Al-Qudsi 2018-10-01 16:48:38 -05:00
parent d7cbf3581d
commit a9845dc026
2 changed files with 5 additions and 0 deletions

View file

@ -46,6 +46,10 @@ wcstring truncate(const wcstring &input, int max_len, ellipsis_type etype) {
return output;
}
wcstring trim(const wcstring &input) {
return trim(input, whitespace.c_str());
}
wcstring trim(const wcstring &input, const wchar_t *any_of) {
auto begin_offset = input.find_first_not_of(any_of);
if (begin_offset == wcstring::npos) {

View file

@ -64,6 +64,7 @@ enum class ellipsis_type {
};
wcstring truncate(const wcstring &input, int max_len, ellipsis_type etype = ellipsis_type::Prettiest);
wcstring trim(const wcstring &input);
wcstring trim(const wcstring &input, const wchar_t *any_of);
#endif