about summary refs log tree commit diff stats
path: root/src/utils/twtstr.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-18 20:37:36 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-18 20:37:36 +0200
commit8a826ba92b7c744a995a9593834d63acd6d040b3 (patch)
tree2b808d8df3d2a0a0994a28b6fd96bc073ad4a24b /src/utils/twtstr.nim
parent2f8edaffdcf22b90389d214b730ea9e28a3b2e5a (diff)
downloadchawan-8a826ba92b7c744a995a9593834d63acd6d040b3.tar.gz
term: simplify/cleanup
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r--src/utils/twtstr.nim9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index c0b68178..7589c262 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -1071,6 +1071,15 @@ func deleteChars*(s: string, todel: set[char]): string =
     inc i
   return rs
 
+func replaceControls*(s: string): string =
+  result = newStringOfCap(s.len)
+  for c in s:
+    if c in Controls:
+      result &= '^'
+      result &= c.getControlLetter()
+    else:
+      result &= c
+
 #https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart/form-data-encoding-algorithm
 proc makeCRLF*(s: string): string =
   result = newStringOfCap(s.len)