]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Invisible name check: detect all utf8 space characters
authorterencehill <piuntn@gmail.com>
Tue, 10 Oct 2017 19:56:23 +0000 (21:56 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 10 Oct 2017 19:56:23 +0000 (21:56 +0200)
qcsrc/lib/string.qh

index b05a316c94a2a4d6b438420d000ce7242f506f19..0a3fb085c1d5fb988298073071745b829578cb3d 100644 (file)
@@ -256,6 +256,7 @@ int u8_strsize(string s)
        return l;
 }
 
+//List of Unicode spaces: https://www.cs.tut.fi/~jkorpela/chars/spaces.html
 ERASEABLE
 bool isInvisibleString(string s)
 {
@@ -272,8 +273,26 @@ bool isInvisibleString(string s)
                        case 192:          // charmap space
                                if (!utf8) break;
                                return false;
-                       case 160:          // space in unicode fonts
                        case 0xE000 + 192: // utf8 charmap space
+                       case 0x00A0: // NO-BREAK SPACE
+                       //case 0x1680: // OGHAM SPACE MARK
+                       case 0x180E: // MONGOLIAN VOWEL SEPARATOR
+                       case 0x2000: // EN QUAD
+                       case 0x2001: // EM QUAD
+                       case 0x2002: // EN SPACE
+                       case 0x2003: // EM SPACE
+                       case 0x2004: // THREE-PER-EM SPACE
+                       case 0x2005: // FOUR-PER-EM SPACE
+                       case 0x2006: // SIX-PER-EM SPACE
+                       case 0x2007: // FIGURE SPACE
+                       case 0x2008: // PUNCTUATION SPACE
+                       case 0x2009: // THIN SPACE
+                       case 0x200A: // HAIR SPACE
+                       case 0x200B: // ZERO WIDTH SPACE
+                       case 0x202F: // NARROW NO-BREAK SPACE
+                       case 0x205F: // MEDIUM MATHEMATICAL SPACE
+                       case 0x3000: // IDEOGRAPHIC SPACE
+                       case 0xFEFF: // ZERO WIDTH NO-BREAK SPACE
                                if (utf8) break;
                        default:
                                return false;