]> git.lyx.org Git - features.git/blobdiff - src/support/lstrings.cpp
Fix Qt6 deprecation warning (QString::fromUcs4(uint))
[features.git] / src / support / lstrings.cpp
index 9aac66a7542616023220622b19c741130a7c5dc8..351c9775cc82a4817238ca9e89da8009bf885229 100644 (file)
@@ -543,6 +543,14 @@ docstring const uppercase(docstring const & a)
 }
 
 
+docstring capitalize(docstring const & s) {
+       docstring ret = s;
+       char_type t = uppercase(ret[0]);
+       ret[0] = t;
+       return ret;
+}
+
+
 string const ascii_lowercase(string const & a)
 {
        string tmp(a);
@@ -967,6 +975,21 @@ int count_char(docstring const & str, docstring::value_type chr)
 }
 
 
+int wordCount(docstring const & d)
+{
+       docstring dt = trim(d);
+       if (dt.empty())
+               return 0;
+       int words = 1;
+       for (auto const & c : dt) {
+               if (isSpace(c))
+                       words++;
+       }
+       return words;
+}
+
+
+
 int count_bin_chars(string const & str)
 {
        QString const qstr = toqstr(str).simplified();