From 3d388558e9bed7bd2226a62ea454ff11942da782 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sat, 9 Nov 2024 11:24:10 +0100 Subject: [PATCH] add braille space to the list of invisible chars --- lila/src/main/scala/StringOps.scala | 4 +++- lila/src/test/scala/StringOpsTest.scala | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lila/src/main/scala/StringOps.scala b/lila/src/main/scala/StringOps.scala index db52e7c..aa44205 100644 --- a/lila/src/main/scala/StringOps.scala +++ b/lila/src/main/scala/StringOps.scala @@ -61,7 +61,9 @@ object StringOps: // weird stuff https://www.compart.com/en/unicode/block/U+2000 (c >= '\u2028' && c <= '\u202F') || // Hangul fillers - (c == '\u115f' || c == '\u1160') + (c == '\u115f' || c == '\u1160') || + // braille space https://unicode-explorer.com/c/2800 + (c == '\u2800') object normalize: diff --git a/lila/src/test/scala/StringOpsTest.scala b/lila/src/test/scala/StringOpsTest.scala index 2d54493..d0fd67d 100644 --- a/lila/src/test/scala/StringOpsTest.scala +++ b/lila/src/test/scala/StringOpsTest.scala @@ -46,3 +46,12 @@ class StringTest extends munit.FunSuite: assertEquals(normalize("keep º and ª"), "keep º and ª") test("normalize preserve half point"): assertEquals(normalize("½"), "½") + + test("invisible chars"): + // normal space + assertEquals(softCleanUp(" "), "") + assertEquals(softCleanUp(" "), "") + // braille space + assertEquals(softCleanUp("⠀"), "") + assertEquals(softCleanUp("⠀⠀⠀"), "") + assertEquals(softCleanUp("⠀uh⠀⠀"), "uh")