diff options
Diffstat (limited to 'src/core/basetypes/MCString.cc')
-rw-r--r-- | src/core/basetypes/MCString.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/basetypes/MCString.cc b/src/core/basetypes/MCString.cc index 054cbb80..3f0338db 100644 --- a/src/core/basetypes/MCString.cc +++ b/src/core/basetypes/MCString.cc @@ -1795,6 +1795,24 @@ String * String::flattenHTML() return flattenHTMLAndShowBlockquote(true); } +String * String::stripWhitespace() +{ + String *str = (String *)copy(); + + str->replaceOccurrencesOfString(MCSTR("\t"), MCSTR(" ")); + str->replaceOccurrencesOfString(MCSTR("\n"), MCSTR(" ")); + str->replaceOccurrencesOfString(MCSTR("\v"), MCSTR(" ")); + str->replaceOccurrencesOfString(MCSTR("\f"), MCSTR(" ")); + str->replaceOccurrencesOfString(MCSTR("\r"), MCSTR(" ")); + + while (str->replaceOccurrencesOfString(MCSTR(" "), MCSTR(" ")) > 0) { + /* do nothing */ + } + + return str; +} + + bool String::hasSuffix(String * suffix) { if (mLength >= suffix->mLength) { |