Add new function to remove non-ascii characters from strings.
[citadel.git] / libcitadel / lib / stringbuf.c
index 9a889ba5e9612e31d65a1122ca58bb5857033a2f..ab9a1814887e4204d21c98572dd5b2eb44f2e83b 100644 (file)
@@ -2540,6 +2540,23 @@ long StrHtmlEcmaEscAppend(StrBuf *Target, const StrBuf *Source, const char *Plai
        return Target->BufUsed;
 }
 
+
+/**
+ * @ingroup StrBuf_DeEnCoder
+ * @brief replace all non-Ascii characters by another
+ * @param Buf buffer to inspect
+ * @param repl charater to stamp over non ascii chars
+ */
+void StrBufAsciify(StrBuf *Buf, const char repl)
+{
+       long offset;
+
+       for (offset = 0; offset < Buf->BufUsed; offset ++)
+               if (!isascii(Buf->buf[offset]))
+                       Buf->buf[offset] = repl;
+       
+}
+
 /**
  * @ingroup StrBuf_DeEnCoder
  * @brief unhide special chars hidden to the HTML escaper