From: Colin Watson Date: Thu, 23 Oct 2003 16:08:42 +0000 (+0000) Subject: isttyutf8: New script to guess whether a terminal speaks UTF-8. Still eats X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=1d3e9a664c9a902354ae9b3218035da818233841;p=bin.git isttyutf8: New script to guess whether a terminal speaks UTF-8. Still eats pending input when invoked, which is a bug. --- diff --git a/isttyutf8 b/isttyutf8 new file mode 100755 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