]> git.lyx.org Git - lyx.git/blobdiff - src/support/lstrings.cpp
Make GraphicsConverter threadsafe
[lyx.git] / src / support / lstrings.cpp
index a2487f88442a84ecf75f9ee375daadb558e12108..8508e4ef1303e06e7e34d3e560b387f7ee142194 100644 (file)
@@ -25,6 +25,7 @@
 #include <cstdio>
 #include <cstring>
 #include <algorithm>
+#include <typeinfo>
 
 using namespace std;
 
@@ -942,6 +943,31 @@ int count_char(docstring const & str, docstring::value_type chr)
 }
 
 
+int count_bin_chars(string const & str)
+{
+       QString const qstr = toqstr(str).simplified();
+       int count = 0;
+       QString::const_iterator cit = qstr.begin();
+       QString::const_iterator end = qstr.end();
+       for (; cit != end; ++cit)  {
+               switch (cit->category()) {
+               case QChar::Separator_Line:
+               case QChar::Separator_Paragraph:
+               case QChar::Other_Control:
+               case QChar::Other_Format:
+               case QChar::Other_Surrogate:
+               case QChar::Other_PrivateUse:
+               case QChar::Other_NotAssigned:
+                       ++count;
+                       break;
+               default:
+                       break;
+               }
+       }
+       return count;
+}
+
+
 docstring const trim(docstring const & a, char const * p)
 {
        LASSERT(p, return a);