#!/bin/sh # showtext 1.4.7 (2002-Nov-10-Sun) # Adam M. Costello # showtext [ ... ] # # Translates windows-1252 characters 128-159 into the nearest ASCII # approximation, fixes line breaks, and replaces vertical tabs, then # invokes the pager. Depends on nawk and tty, and on xterm if DISPLAY # is set and stdout is not a terminal. # # Reference: # http://www.microsoft.com/globaldev/reference/sbcs/1252.htm # 0x80 U+20AC euro sign ----------------------------------> EU$ # 0x81 unused # 0x82 U+201A single low-9 quotation mark ----------------> , # 0x83 U+0192 Latin small letter f with hook -------------> f # 0x84 U+201E double low-9 quotation mark ----------------> ,, # 0x85 U+2026 horizontal ellipsis ------------------------> ... # 0x86 U+2020 dagger -------------------------------------> (+) # 0x87 U+2021 double dagger ------------------------------> (++) # 0x88 U+02C6 modifier letter circumflex accent ----------> ^ # 0x89 U+2030 per mille sign -----------------------------> 0/00 # 0x8A U+0160 Latin capital letter s with caron ----------> S # 0x8B U+2039 single left-pointing angle quotation mark --> < # 0x8C U+0152 Latin capital ligature OE ------------------> OE # 0x8D unused # 0x8E U+017D Latin capital letter Z with caron ----------> Z # 0x8F unused # 0x90 unused # 0x91 U+2018 left single quotation mark -----------------> ` # 0x92 U+2019 right single quotation mark ----------------> ' # 0x93 U+201C left double quotation mark -----------------> " # 0x94 U+201D right double quotation mark ----------------> " # 0x95 U+2022 bullet -------------------------------------> * # 0x96 U+2013 en dash ------------------------------------> - # 0x97 U+2014 em dash ------------------------------------> -- # 0x98 U+02DC small tilde --------------------------------> ~ # 0x99 U+2122 trade mark sign ----------------------------> (TM) # 0x9A U+0161 Latin small letter s with caron ------------> s # 0x9B U+203A single right-pointing angle quotation mark -> > # 0x9C U+0153 Latin small ligature oe --------------------> oe # 0x9D unused # 0x9E U+017E Latin small letter z with caron ------------> z # 0x9F U+0178 Latin capital letter Y with diaeresis ------> Y # 0x0b (vertical tab) is replaced with three newlines. # 0x0d (CR) is removed at the end of a line, replaced with LF in the # middle of a line. name=showtext nawk=nawk tmpfile=/tmp/showtext$$ quit() { rm -f $tmpfile exit $1 } fix() { $nawk '{ gsub(/\200/, "EU$"); gsub(/\202/, ","); gsub(/\203/, "f"); gsub(/\204/, ",,"); gsub(/\205/, "..."); gsub(/\206/, "(+)"); gsub(/\207/, "(++)"); gsub(/\210/, "^"); gsub(/\211/, " 0/00"); gsub(/\212/, "S"); gsub(/\213/, "<"); gsub(/\214/, "OE"); gsub(/\221/, "`"); gsub(/\222/, "'\''"); gsub(/\223/, "\""); gsub(/\224/, "\""); gsub(/\225/, "*"); gsub(/\226/, "-"); gsub(/\227/, "--"); gsub(/\230/, "~"); gsub(/\231/, "(TM)"); gsub(/\232/, "s"); gsub(/\233/, ">"); gsub(/\234/, "oe"); gsub(/\237/, "Y"); gsub(/\013/, "\012\012\012"); sub(/\015$/, ""); gsub(/\015/, "\012"); print; }' } # Include metamail headers if present: if [ -n "$MM_HEADERS" ]; then $nawk '$0 != "" { print; } END { print ""; } ' << !EOF! $MM_HEADERS !EOF! fi | fix > $tmpfile # Fix Windows characters: case $# in 0) fix ;; 1) fix < "$1" ;; *) cat "$@" | fix ;; esac >> $tmpfile # See if we have a tty: if tty <&1 > /dev/null 2> /dev/null; then tty=yes else tty=no fi # Start the pager: if [ $tty = yes ]; then ${PAGER-more} $tmpfile elif [ -n "$DISPLAY" ]; then xterm -T $name -n $name -name $name \ -e $SHELL -c "exec ${PAGER-more} $tmpfile" else echo "no tty and no DISPLAY" >&2 quit 1 fi quit 0