|
Lines 87-97
Link Here
|
| 87 |
shift |
87 |
shift |
| 88 |
done |
88 |
done |
| 89 |
|
89 |
|
|
|
90 |
# special hack to display Japanese and Czech man pages correctly in UTF-8 locale: |
| 91 |
ICONV="cat" |
| 92 |
case "`locale charmap 2>/dev/null`" in |
| 93 |
UTF-8) |
| 94 |
case "${LANGUAGE-${LC_ALL-${LC_MESSAGES-${LANG}}}}" in |
| 95 |
ja*) |
| 96 |
# Japanese man page in UTF-8 locale, special case! |
| 97 |
# force the device 'nippon' to run groff in ja_JP.eucJP locale |
| 98 |
# and convert the result to UTF-8 using iconv: |
| 99 |
T=-Tnippon |
| 100 |
export LC_ALL=ja_JP.eucJP |
| 101 |
ICONV="iconv -f EUC-JP -t UTF-8" |
| 102 |
;; |
| 103 |
cs*|hu*|hr*|pl*) |
| 104 |
# Czech, Hungarian, ... in UTF-8 seem to need special treatment as well: |
| 105 |
T=-Tascii8 |
| 106 |
export LC_ALL=cs_CZ.ISO-8859-2 |
| 107 |
ICONV="iconv -f ISO-8859-2 -t UTF-8" |
| 108 |
;; |
| 109 |
ru_RU*) |
| 110 |
# Russian man page sources are in KOI8-R |
| 111 |
T=-Tascii8 |
| 112 |
export LC_ALL=ru_RU.KOI8-R |
| 113 |
ICONV="iconv -f KOI8-R -t UTF-8" |
| 114 |
;; |
| 115 |
# make 'man iso-8859-15' display correctly in UTF-8 locales using Euro |
| 116 |
ca_ES*|de_AT*|de_BE*|de_DE*|de_LU*|en_BE*|en_IE*|es_ES*|eu_ES*|fi_FI*|fr_BE*|fr_FR*|fr_LU*|ga_IE*|gl_ES*|it_IT*|nl_BE*|nl_NL*|pt_PT*|sv_FI*|wa_BE*) |
| 117 |
T=-Tascii8 |
| 118 |
export LC_ALL=de_DE@euro |
| 119 |
ICONV="iconv -f ISO-8859-15 -t UTF-8" |
| 120 |
;; |
| 121 |
esac |
| 122 |
;; |
| 123 |
esac |
| 124 |
|
| 125 |
guess_legacy_encoding () { |
| 126 |
# Guess the legacy encoding used by the language/country |
| 127 |
# found in the current LC_CTYPE value. |
| 128 |
|
| 129 |
# First determine the LC_CTYPE locale category setting |
| 130 |
ctype=${LC_ALL-${LC_CTYPE-${LANG-en_US}}} |
| 131 |
|
| 132 |
case $ctype in |
| 133 |
zh_TW*) |
| 134 |
LEGACY_ENCODING=Big5 |
| 135 |
;; |
| 136 |
zh_HK*) |
| 137 |
LEGACY_ENCODING=Big5HKSCS |
| 138 |
;; |
| 139 |
zh*) |
| 140 |
LEGACY_ENCODING=GB2312 |
| 141 |
;; |
| 142 |
ja*) |
| 143 |
LEGACY_ENCODING=EUC-JP |
| 144 |
;; |
| 145 |
ko*) |
| 146 |
LEGACY_ENCODING=EUC-KR |
| 147 |
;; |
| 148 |
ru*) |
| 149 |
LEGACY_ENCODING=KOI8-R |
| 150 |
;; |
| 151 |
uk*) |
| 152 |
LEGACY_ENCODING=KOI8-U |
| 153 |
;; |
| 154 |
pl*|hr*|hu*|cs*|sk*|sl*) |
| 155 |
LEGACY_ENCODING=ISO-8859-2 |
| 156 |
;; |
| 157 |
eo*|mt*) |
| 158 |
LEGACY_ENCODING=ISO-8859-3 |
| 159 |
;; |
| 160 |
el*) |
| 161 |
LEGACY_ENCODING=ISO-8859-7 |
| 162 |
;; |
| 163 |
he*) |
| 164 |
LEGACY_ENCODING=ISO-8859-8 |
| 165 |
;; |
| 166 |
tr*) |
| 167 |
LEGACY_ENCODING=ISO-8859-9 |
| 168 |
;; |
| 169 |
th*) |
| 170 |
LEGACY_ENCODING=TIS-620 # or ISO-8859-11 |
| 171 |
;; |
| 172 |
lt*) |
| 173 |
LEGACY_ENCODING=ISO-8859-13 |
| 174 |
;; |
| 175 |
cy*) |
| 176 |
LEGACY_ENCODING=ISO-8859-14 |
| 177 |
;; |
| 178 |
ro*) |
| 179 |
LEGACY_ENCODING=ISO-8859-14 # or ISO-8859-16 |
| 180 |
;; |
| 181 |
am*|vi*) |
| 182 |
LEGACY_ENCODING=UTF-8 |
| 183 |
;; |
| 184 |
*) |
| 185 |
LEGACY_ENCODING=ISO-8859-1 |
| 186 |
;; |
| 187 |
esac |
| 188 |
} |
| 189 |
|
| 190 |
guess_legacy_encoding; |
| 191 |
TMPDIR=`mktemp -d /tmp/nroff.XXXXXX` |
| 192 |
if [ $? -ne 0 ]; then |
| 193 |
echo "$0: Can't create temp directory, exiting..." |
| 194 |
exit 1 |
| 195 |
fi |
| 196 |
|
| 197 |
trap "exec rm -rf $TMPDIR" EXIT SIGHUP SIGINT SIGPIPE SIGTERM SIGIO |
| 198 |
cat > $TMPDIR/standard_input |
| 199 |
iconv -s -c -f utf-8 -t utf-8 < $TMPDIR/standard_input > /dev/null |
| 200 |
if [ $? -eq 0 ]; then |
| 201 |
iconv -s -c -f utf8 -t $LEGACY_ENCODING < $TMPDIR/standard_input > $TMPDIR/standard_input.new |
| 202 |
mv $TMPDIR/standard_input.new $TMPDIR/standard_input |
| 203 |
fi |
| 204 |
|
| 90 |
# This shell script is intended for use with man, so warnings are |
205 |
# This shell script is intended for use with man, so warnings are |
| 91 |
# probably not wanted. Also load nroff-style character definitions. |
206 |
# probably not wanted. Also load nroff-style character definitions. |
| 92 |
|
207 |
|
| 93 |
: ${GROFF_BIN_PATH=@BINDIR@} |
208 |
: ${GROFF_BIN_PATH=@BINDIR@} |
| 94 |
export GROFF_BIN_PATH |
209 |
export GROFF_BIN_PATH |
| 95 |
PATH=$GROFF_BIN_PATH:$PATH groff -mtty-char $T $opts ${1+"$@"} |
210 |
PATH=$GROFF_BIN_PATH:$PATH groff -mtty-char $T $opts ${1+"$@"} < $TMPDIR/standard_input | $ICONV |
| 96 |
|
211 |
|
| 97 |
# eof |
212 |
# eof |