]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/string.qh
Cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / string.qh
index 2bf9ac1f7b5c8a5f6ddac99a14ce2a15134937e7..048b5c721b9d7365b60240109b8b06495ce55881 100644 (file)
@@ -184,4 +184,29 @@ int u8_strsize(string s)
        return l;
 }
 
+bool isInvisibleString(string s)
+{
+       s = strdecolorize(s);
+       bool utf8 = cvar("utf8_enable");
+       for (int i = 0, n = strlen(s); i < n; ++i)
+       {
+               int c = str2chr(s, i);
+               switch (c)
+               {
+                       case 0:
+                       case 32:           // space
+                               break;
+                       case 192:          // charmap space
+                               if (!utf8) break;
+                               return false;
+                       case 160:          // space in unicode fonts
+                       case 0xE000 + 192: // utf8 charmap space
+                               if (utf8) break;
+                       default:
+                               return false;
+               }
+       }
+       return true;
+}
+
 #endif