Just some stuff about me.
Here's my dotfiles repository.
What links here:
utf8_or_ascii() {
old_settings=$(stty -g)
stty -icanon -echo min 0 time 3
printf '€'
printf '\033[6n' # getcursorpos VT100 escape code
# response: ^[v;hR - i.e cursor at row v, col h
pos=$(dd count=1 2>/dev/null)
pos=${pos%%R*}
pos=${pos##*\[}
col=${pos##*;}
#row=${pos%%;*}
stty "$old_settings"
if [ "$col" -eq 2 ]; then
printf 'UTF8'
else
printf 'ASCII'
fi
}