summary refs log tree commit diff
path: root/www/text.causal.agency/colb.c
diff options
context:
space:
mode:
authorC. McEnroe <june@causal.agency>2021-09-26 13:00:12 -0400
committerC. McEnroe <june@causal.agency>2021-09-26 16:53:21 -0400
commit69ea054270bc43c00937015b78378de9dc649602 (patch)
tree062df05f1174456c9961b6b003b65b2aecf38fc5 /www/text.causal.agency/colb.c
parentInstall up to cgi-bin (diff)
downloadsrc-69ea054270bc43c00937015b78378de9dc649602.tar.gz
src-69ea054270bc43c00937015b78378de9dc649602.zip
Use tiny UTF-8-aware col -b replacement
OpenBSD col(1) doesn't understand UTF-8 and will delete all of it.
Stupid, especially when mandoc(1) tells you to use it to remove man
formatting. I shouldn't have to write something so trivial.
Diffstat (limited to 'www/text.causal.agency/colb.c')
-rw-r--r--www/text.causal.agency/colb.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/www/text.causal.agency/colb.c b/www/text.causal.agency/colb.c
new file mode 100644
index 0000000..5faabc3
--- /dev/null
+++ b/www/text.causal.agency/colb.c
@@ -0,0 +1,16 @@
+#include <locale.h>
+#include <stdio.h>
+#include <wchar.h>
+int main(void) {
+	setlocale(LC_CTYPE, "en_US.UTF-8");
+	wint_t next, prev = WEOF;
+	while (WEOF != (next = getwchar())) {
+		if (next == L'\b') {
+			prev = WEOF;
+		} else {
+			if (prev != WEOF) putwchar(prev);
+			prev = next;
+		}
+	}
+	if (prev != WEOF) putwchar(prev);
+}