chiark / gitweb /
isttyutf8: New script to guess whether a terminal speaks UTF-8. Still eats
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Thu, 23 Oct 2003 16:08:42 +0000 (16:08 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Thu, 23 Oct 2003 16:08:42 +0000 (16:08 +0000)
pending input when invoked, which is a bug.

isttyutf8 [new file with mode: 0755]

diff --git a/isttyutf8 b/isttyutf8
new file mode 100755 (executable)
index 0000000..2b3d9b9
--- /dev/null
+++ b/isttyutf8
@@ -0,0 +1,12 @@
+#! /bin/sh
+set -e
+
+[ -t 0 ] || exit 1
+
+# TODO: eats pending keystrokes somehow.
+result="$(ctlseq -r -R CR "$(printf '\xc3\xb6')" CSI 6 n CR SP SP CR)"
+if expr "$result" : '.\+;2R' >/dev/null; then
+    exit 0
+else
+    exit 1
+fi