summaryrefslogtreecommitdiff
path: root/tools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools.cpp')
-rw-r--r--tools.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools.cpp b/tools.cpp
index de0b43c..beded35 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -71,4 +71,16 @@ string StringRepeat(int times, const string& input)
return result;
}
+string StringWordTruncated(const string& input, size_t maxLen, bool& truncated)
+{
+ if (input.length() <= maxLen)
+ {
+ return input;
+ }
+ truncated = true;
+ string result = input.substr(0, maxLen);
+ size_t pos = result.find_last_of(" \t,;:.\n?!'\"/\\()[]{}*+-");
+ return result.substr(0, pos);
+}
+
} // namespace vdrlive