#!/bin/sh # KOI8R E: 0xA3, 0xB3 ? # http://kiarchive.relcom.ru/pub/internet/rfc/rfc1489.txt # http://www.orgland.ru/~maxim/charsets.images.html#koi help=" tr $0 [-A | -a | -k | ... ] file1 file2 -A | -ALT - -a | -alt - -K | -KOI - Koi8 --> Besta -k | -koi - Besta --> Koi8 -I | -ISO - ISO -i | -iso - Besta ISO -W | -WIN - Windows -w | -win - Besta Windows -UTF8 - Word-8 UTF-8 Windows -utf8 - Windows UTF-8 -MAC - Macintosh -MACB - Macintosh -MACYR - Macintosh -mac - Besta Macintosh -KOI7 - True KOI7 --> ( -- 7.) -KOI7T - KOI7 -koi7 - --> true KOI7 (|TO -- NASTOQ]IJ gost koi7.) -RKOI7 - Readable KOI7 --> ( 7.) -rkoi7 - --> readable KOI7 (~itabelxnyj GOST KOI7.) -R | -rus - Transliteraciq --> -r | -lat - --> Transliteraciq -b | -down - -B | -UP - -s | -sparc - KOI SPARCprinter-russian -M | -CRLFLF - CRLF --> LF ( dos --> UNIX) -m | -lfcrlf - LF --> CRLF (UNIX --> dos ) -L | -LETTER - ceouuua -TU - ^T^U ASCII -FIDO - ceoupuuy -P - ceouuua -p - pp "p" "" -fido - pp "" --> "H", "" --> "p" -rk RK- -altram ALT- -altramwin ALT- -koiram KOI- -bach2rk -iwasi2rk -rk2pcl RK HP laserjet II -mosaic2rk Nestscape Hex Encoding to besta -man2rk catman format Rk- -rtf2rk RTF -GAK , -GOS GAK - -NNF .. -NNF2 -PRUD , -index2dir index.html .dir -EOP -ABZAC -abzac -REABZAC . -LINE , -OTSTUP -OTSTUP2 -WW -6 moshkow.txt -WWC -6-courier moshkow.txt -WWID [Author ID...] -LYR .lyr -AKSRUS -HEX 0xef -- ASCII -ANS Word DOC As text with layout -ASC Word DOC As text with layout -LEX -COM anticomma - -CT1CU -psewdo rk -preformat "==" - -PERENOS -PREFORMAT "==" "--" -HARRY -wfor doc- -hlebnikow MS- html- -MAN NROFF RK -NAB html -NA html -NA2 -8- html . -AKM "" -AHREF "" http- -SKRIZHALI html -SH -KRU -LIB html-lib.ru .txt -TEXTSHARE -MSHTML MS-html -NOHTML html -NOHTMLIB html -UTFHTML aqute - -UTFNUM [] -mime To Nestscape Hex Encoding -MIME From Nestscape Hex Encoding -UNIW UNICODE-windows -- А П Я - 1040 + 192 -uni Windows unicode -uniw UNICODE-windows -- А П Я - 1040 + 192 -UNI UNICODE ascii А a -oct To octanumeric -LADA -KW kword RH 7.3 -NO -WH MS- -WHC MS- -RTF -1251-rtf plaintext " CAT=cat export CAT # . - yo LC_CTYPE=C export LC_CTYPE # CAT=ALTYO export CAT KOI_help() { echo "$@ $help" } KBD='qwertyuiop[]asdfghjkl;'"'"'zxcvbnm,.QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>''/=1567902' BEST='R'""'''e?!:,.()-' BESTA="R?" LATIN='ABWGDEVZIJKLMNOPRSTUFHC+{}YX|~Qabwgdevzijklmnoprstufhc=\133\135Ryx\\`q?' RKOI7='ABWGDEVZIJKLMNOPRSTUFHC^[]_YX\\@Qabwgdevzijklmnoprstufhc~{}_yx|`q?' KOI7T='ABVGDE}ZIHKLMNOPRSTUFXC|WQ:{"+YJabvgde]zihklmnoprstufxc\\wq;['"'"'=yj?' KOI7='abwgdevzijklmnoprstufhc~{}_yx|`qABWGDEVZIJKLMNOPRSTUFHC^[]\177YX\\@Q?' SPARC="abcdefghijklmnopqrstuvwxyzRABCDEFGHIJKLMNOPQRSTUVWXYZ?" KOI="\377?" ISO='+?????'?????' WIN="\377?" ALTERNAT="\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357?" GAK="\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\232\241\242\243\244\245\246\247\263\277\252\253\254\255\256\257\301\302\327\307\304\305\326\332\311\312\352\314\315\355\317\320\300" GOS="\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\232\241\242\270\244\245\246\247\263\277\252\253\254\255\256\257\301\302\327\307\304\305\326\332\311\312\313\314\315\316\317\320\300" MAC="\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377?" BOLXSHIE="ABCDEFGHIJKLMNOPQRSTUVWXYZ?" malenxkie="abcdefghijklmnopqrstuvwxyz?" LETTERS='acpyeuoxcnmETOPAHKXCBM' BUKWY='' NNF='.' nnf=''\234?.???\232?\230\222\237??+?\235' NNF2='''''''''''''''' nnf2='???????\237\235\203\220\236' TRANSLATOR=tr UNIXORDOS=cat ECHO=echo case "$OSTYPE" in Linux|linux*) ECHO="echo -e" ;; SunOS*)case `uname -a` in *4.1*|SunOS4*) ECHO=/usr/5bin/echo ;; esac ;; "") case `uname -a` in SunOS*4.1*|SunOS4*) ECHO=/usr/5bin/echo ;; esac ;; esac LC_ALL=C export LC_ALL CTRL_M=`$ECHO "\015"` ESC=`$ECHO "\033"` # while # # [ X != "X$*" ] # do case "$1" in -a|-alt) FROM="$KOI" INTO="$ALTERNAT" UNIXORDOS=unix2dos ; shift ;; -A|-ALT) CAT=ALTYO FROM="$ALTERNAT" INTO="$KOI" UNIXORDOS=dos2unix ; shift ;; -GAK) FROM="$GAK" INTO="$KOI" UNIXORDOS=dos2unix ; shift ;; -GOS) FROM="$GOS" INTO="$KOI" UNIXORDOS=dos2unix ; shift ;; -NNF) FROM="$nnf" INTO="$NNF" ; shift ;; -NNF2) FROM="$nnf2" INTO="$NNF2" ; shift ;; -k|-koi) FROM="$BESTA" INTO="$KOI" ; shift ;; -K|-KOI) FROM="$KOI" INTO="$BESTA" ; shift ;; -i|-iso) FROM="$KOI" INTO="$ISO" ; shift ;; -I|-iso) FROM="$ISO" INTO="$KOI" ; shift ;; -w|-win) FROM="$KOI" INTO="$WIN" ; shift ;; -W|-WIN) FROM="$WIN" INTO="$KOI" UNIXORDOS=dos2unix ; shift ;; -MAC) FROM="$MAC"'' INTO="$KOI"'""""-' ; shift ;; -KOI7T) FROM="$KOI7T"'`%' INTO="$KOI"'e"' ; shift ;; -MACB) FROM="$MAC" INTO="$KOI" ; shift ;; -KBD) FROM="$KBD" INTO="$BEST" ; shift ;; -mac) FROM="$KOI" INTO="$MAC" ; shift ;; -KOI7) FROM="$KOI7" INTO="$KOI" ; shift ;; -koi7) FROM="$KOI" INTO="$KOI7" ; shift ;; -RKOI7) FROM="$RKOI7" INTO="$KOI" ; shift ;; -rkoi7) FROM="$KOI" INTO="$RKOI7" ; shift ;; -r|-lat) FROM="$KOI" INTO="$LATIN" ; shift ;; -R|-rus|-RUS) FROM="$LATIN" INTO="$KOI" ; shift ;; -s|-sparc) FROM="$KOI" INTO="$SPARC" ; shift ;; -L|-LETTER) FROM="$LETTERS" INTO="$BUKWY" ; shift ;; -b|-down) FROM="$BOLXSHIE" INTO="$malenxkie" ; shift ;; -B|-UP) FROM="$malenxkie" INTO="$BOLXSHIE" ; shift ;; -FIDO) FROM="$BUKWY" INTO="$LETTERS" ; shift ;; -UTF8) TRANSLATOR=cat UNIXORDOS=UTF8 ; shift ;; -utf8) TRANSLATOR=cat UNIXORDOS=utf8n ; shift ;; -TU) TRANSLATOR=cat UNIXORDOS=TU ; shift ;; -M|-CRLFLF) TRANSLATOR=cat UNIXORDOS=dos2unix ; shift ;; -m|-lfcrlf) TRANSLATOR=cat UNIXORDOS=unix2dos ; shift ;; -p) TRANSLATOR=cat UNIXORDOS=antip ; shift ;; -fido) TRANSLATOR=cat UNIXORDOS=tofido ; shift ;; -P) TRANSLATOR=cat UNIXORDOS=antiwse ; shift ;; -rk) TRANSLATOR=cat UNIXORDOS=anticolorramki; shift ;; -koiram) TRANSLATOR=cat UNIXORDOS=antikoiramki ; shift ;; -altram) TRANSLATOR=cat UNIXORDOS=altram ; shift ;; -altramwin) TRANSLATOR=cat UNIXORDOS=altramkiwin ; shift ;; -bach2rk) TRANSLATOR=cat UNIXORDOS=bach2rk ; shift ;; -iwasi2rk) TRANSLATOR=cat UNIXORDOS=iwasi2rk ; shift ;; -mosaic2rk) TRANSLATOR=cat UNIXORDOS=mosaic2rk ; shift ;; -rk2pcl) TRANSLATOR=cat UNIXORDOS=rk2pcl ; shift ;; -man2rk) TRANSLATOR=cat UNIXORDOS=man2rk ; shift ;; -RTF2RK) TRANSLATOR=cat UNIXORDOS=RTF2RK ; shift ;; -index2dir) TRANSLATOR=cat UNIXORDOS=index2dir; shift ;; -EOP) TRANSLATOR=cat UNIXORDOS=eop ; shift ;; -ABZAC) TRANSLATOR=cat UNIXORDOS=ABZAC ; shift ;; -abzac) TRANSLATOR=cat UNIXORDOS=abzac ; shift ;; -oTSTUP) TRANSLATOR=cat UNIXORDOS=oTSTUP ; shift ;; -OTSTUP) TRANSLATOR=cat UNIXORDOS=OTSTUP ; shift ;; -OTSTUP2) TRANSLATOR=cat UNIXORDOS=OTSTUP2 ; shift ;; -WW) TRANSLATOR=cat UNIXORDOS=WW ; shift ;; -WWC) TRANSLATOR=cat UNIXORDOS=WWC ; shift ;; -WWID) TRANSLATOR=cat UNIXORDOS=WWID ; shift ;; -KW) TRANSLATOR=cat UNIXORDOS=KW ; shift ;; -LYR) TRANSLATOR=cat UNIXORDOS=lyr ; shift ;; -AKSRUS) TRANSLATOR=cat UNIXORDOS=aksrus ; shift ;; -HEX) TRANSLATOR=cat UNIXORDOS=fromhex ; shift ;; -ANS) TRANSLATOR=cat UNIXORDOS=ANS ; shift ;; -ASC) TRANSLATOR=cat UNIXORDOS=ASC ; shift ;; -LEX) TRANSLATOR=cat UNIXORDOS=LEX ; shift ;; -COM) TRANSLATOR=cat UNIXORDOS=anticomma ; shift ;; -CT1CU) TRANSLATOR=cat UNIXORDOS=CT1CU ; shift ;; -PRUD) TRANSLATOR=cat UNIXORDOS=PRUD ; shift ;; -HRAM) TRANSLATOR=cat UNIXORDOS=HRAM ; shift ;; -PERENOS) TRANSLATOR=cat UNIXORDOS=PERENOS ; shift ;; -preformat) TRANSLATOR=cat UNIXORDOS=preformat; shift ;; -PREFORMAT) TRANSLATOR=cat UNIXORDOS=PREFORMAT; shift ;; -FORMAT) TRANSLATOR=cat UNIXORDOS=FORMAT ; shift ;; -wfor) TRANSLATOR=cat UNIXORDOS=wfor ; shift ;; -psewdo) TRANSLATOR=cat UNIXORDOS=psewdo ; shift ;; -hlebnikow) TRANSLATOR=cat UNIXORDOS=hlebnikow; shift ;; -MAN) TRANSLATOR=cat UNIXORDOS=MAN ; shift ;; -NAB) TRANSLATOR=cat UNIXORDOS=NAB ; shift ;; -NA) TRANSLATOR=cat UNIXORDOS=NA ; shift ;; -NA2) TRANSLATOR=cat UNIXORDOS=NA2 ; shift ;; -NA3) TRANSLATOR=cat UNIXORDOS=NA3 ; shift ;; -SKRIZHALI) TRANSLATOR=cat UNIXORDOS=SKRIZHALI; shift ;; -SH) TRANSLATOR=cat UNIXORDOS=SH ; shift ;; -KRU) TRANSLATOR=cat UNIXORDOS=KRU ; shift ;; -AHREF) TRANSLATOR=cat UNIXORDOS=AHREF ; shift ;; -HARRY) TRANSLATOR=cat UNIXORDOS=harry ; shift ;; -AKM) TRANSLATOR=cat UNIXORDOS=AKM ; shift ;; -LIB) TRANSLATOR=cat UNIXORDOS=LIB ; shift ;; -TEXTSHARE) TRANSLATOR=cat UNIXORDOS=TEXTSHARE; shift ;; -sort|-SORT) TRANSLATOR=cat UNIXORDOS=SORT ; shift ;; -REABZAC) TRANSLATOR=cat UNIXORDOS=REABZAC ; shift ;; -LINE) TRANSLATOR=cat UNIXORDOS=LINE ; shift ;; -MSHTML) TRANSLATOR=cat UNIXORDOS=MSHTML ; shift ;; -NOHTML) TRANSLATOR=cat UNIXORDOS=NOHTML ; shift ;; -NOHTMLIB) TRANSLATOR=cat UNIXORDOS=NOHTMLIB ; shift ;; -UTFHTML) TRANSLATOR=cat UNIXORDOS=UTFHTML ; shift ;; -UTFNUM) TRANSLATOR=cat UNIXORDOS=UTFNUM ; shift ;; -mime) TRANSLATOR=cat UNIXORDOS=mime ; shift ;; -MIME) TRANSLATOR=cat UNIXORDOS=MIME ; shift ;; -UNIW) TRANSLATOR=cat UNIXORDOS=UNIW ; shift ;; -uniw) TRANSLATOR=cat UNIXORDOS=uniw ; shift ;; -sx1) TRANSLATOR=cat UNIXORDOS=sx1 ; shift ;; -SX1) TRANSLATOR=cat UNIXORDOS=SX1 ; shift ;; -oct) TRANSLATOR=cat UNIXORDOS=oct ; shift ;; -LADA) TRANSLATOR=cat UNIXORDOS=LADA ; shift ;; -NO) TRANSLATOR=cat UNIXORDOS=cat ; shift ;; -WH) TRANSLATOR=cat UNIXORDOS=WH ; shift ;; -WHC) TRANSLATOR=cat UNIXORDOS=WHC ; shift ;; -RTF) TRANSLATOR=cat UNIXORDOS=RTF ; shift ;; -*|-*help) KOI_help ; exit 1 ;; *) FROM="$BESTA" INTO="$KOI" ;; esac ALTYO() { # e: e # cat $1 | tr '0xF00xF10xF20xF3' '\2450xAA0xBA0xAF0xBF' cat $1 | tr '' '\245' } dos2unix() # ^M^J ^J { sed -e "s/$CTRL_M$//" #awk '{sub("\015+$","");print}' } unix2dos() # ^J ^M^J { # sed -e "/$CTRL_M$/ !s/^.*$/&$CTRL_M/" # sed -e "s/$/$CTRL_M/" awk '{print $0 "'$CTRL_M'"}' } antip() # pp "p" p "" { sed -e ' s/\([^ -~]\)p/\1/g s/p\([^ -~]\)/\1/g ' $1 } antiwse() { CTRL_I=`$ECHO "\011"` sed -e " s/?//g s/\([^$CTRL_I-~]\)a/\1/g s/a\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)c/\1/g s/c\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)p/\1/g s/p\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)y/\1/g s/y\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)e/\1/g s/e\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)u/\1/g s/u\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)o/\1/g s/o\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)x/\1/g s/x\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)c/\1/g s/c\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)n/\1/g s/n\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)m/\1/g s/m\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)E/\1/g s/E\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)T/\1/g s/T\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)O/\1/g s/O\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)P/\1/g s/P\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)A/\1/g s/A\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)H/\1/g s/H\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)K/\1/g s/K\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)X/\1/g s/X\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)C/\1/g s/C\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)B/\1/g s/B\([^$CTRL_I-~]\)/\1/g s/\([^$CTRL_I-~]\)M/\1/g s/M\([^$CTRL_I-~]\)/\1/g " } tofido() { tr '[]' '[Hp]' } rk2pcl() { kommentarij=' [\]^ ^^D reverse ^^E ^T underline ^U ^\ dim ^] ' UND_S=`$ECHO "\024"` UND_E=`$ECHO "\025"` REV_S=`$ECHO "\036D"` REV_E=`$ECHO "\036E"` DIM_S=`$ECHO "\034"` DIM_E=`$ECHO "\035"` und_s="${ESC}\&dD" und_e="${ESC}\&d@" rev_s="" rev_e="" dim_s="" dim_e="" sed -e " s/${UND_S}/${und_s}/g s/${UND_E}/${und_e}/g s/${DIM_S}/${dim_s}/g s/${DIM_E}/${dim_e}/g s/${REV_S}/${rev_s}/g s/${REV_E}/${rev_e}/g " } antikoiramki() { #CTRL_KR=`$ECHO "\036"` #CTRL_KRASKI=`$ECHO "[\024\025\034\035]"` # ^T^U^\^] UGOLKI=`$ECHO "[\231\213\230\214\202\204\205]"` # pqbd p bd PEREKL=`$ECHO "[\234\211\237??\210]"` # ^|^ -| |- _|_ -| -|- WERT=`$ECHO "[\212\201]"` # | || GORIZ=`$ECHO "[\235]"` # - perekl=`$ECHO "[\206\207??]"` # + goriz=`$ECHO "[\200]"` # - wert=`$ECHO "[\203]"` # | | sed -e " s/$UGOLKI/+/g s/$PEREKL/+/g s/$perekl/+/g s/$WERT/|/g s/$GORIZ/-/g s/$wert/|/g s/$goriz/-/g " } altramkiwin() { UGOLKI='[???']' # pqbd p bd PEREKL='[?]' goriz="[]" # - werti="[?]" # | sed -e " s/$goriz/-/g s/$werti/|/g s/$UGOLKI/+/g s/$PEREKL/+/g " } altram() { UGOLKI='[??'?]' # pqbd p bdpqbd PEREKL='[]' GORIZ="[]" # = goriz="[]" # - wert="[?]" # | WERT="[?]" # |I sed -e " s/$goriz/-/g s/$GORIZ/=/g s/$WERT/I/g s/$wert/|/g s/$UGOLKI/+/g s/$PEREKL/+/g s%%o%g " } bach2rk() { CTRL_T=`$ECHO "\024"` # ^T CTRL_U=`$ECHO "\025"` # ^U UGOLKI=`$ECHO "[\232\231\200?]"` # pqbd p bd PEREKL=`$ECHO "[\205\203\202\201?]"` # ^|^ -| |- _|_ -| -|- WERT=`$ECHO "[?]"` # | || GORIZ=`$ECHO "[\204]"` # - sed -e " s/${ESC}E/ $CTRL_T/g s/${ESC}F/$CTRL_U/g s/$UGOLKI/+/g s/$PEREKL/+/g s/$WERT/|/g s/$GORIZ/-/g " } iwasi2rk() { CTRL_A=`$ECHO "\001"` # CTRL_T=`$ECHO "\024"` # CTRL_Z=`$ECHO "\031"` # sed -e " s/[${CTRL_A}-${CTRL_Z}]//g s/${ESC}E/${CTRL_T}/g s/${ESC}.//g " } anticolorramki() { CTRL_KR=`$ECHO "\036"` CTRL_KRASKI=`$ECHO "[\024\025\034\035]"` # ^T^U^\^] UGOLKI=`$ECHO "\203[\201\202\203\204\221\222\223\224]"` # pqbd PEREKL=`$ECHO "\203[\205\206\207\210\211]"` # ^|^ -| |- _|_ -| -|- WERT=`$ECHO "\203[\212\232]"` # | || GORIZ=`$ECHO "\203[\213\233]"` # - perekl=`$ECHO "\205[\226]"` # + goriz=`$ECHO "\205[\202\204]"` # - wert=`$ECHO "\205[\201\203\205]"` # | | sed -e " s/$CTRL_KR.//g s/$CTRL_KRASKI//g s/$UGOLKI/+/g s/$PEREKL/+/g s/$perekl/+/g s/$WERT/|/g s/$GORIZ/-/g s/$wert/|/g s/$goriz/-/g " } mosaic2rk() { # s/%E1//g - AWK sed -e "`gawk 'BEGIN {for (i=192; i<=254 ; i=i+1) { printf ("s/[%%=]%2X/%c/g\n", i, i)}}' < /dev/null`" -e ' s/%22/"/g s/%20/ /g s/%3D/=/g s/%3F/?/g s/%5B/[/g s/%5D/]/g ' } man2rk() { UND_S=`$ECHO "\024"` UND_E=`$ECHO "\025"` REV_S=`$ECHO "\036D"` REV_E=`$ECHO "\036E"` Home=`$ECHO "\010"` # Home sed -e " s/_$Home\([^_]\)/$UND_S\1$UND_E/g s/.$Home\(.\)/$REV_S\1$REV_E/g s/$UND_E$UND_S//g s/$REV_E$REV_S//g " } RTF2RK() { sed -e ' s/à//g s/á//g s/â//g s/ã//g s/ä//g s/å//g s/æ//g s/ç//g s/è//g s/é//g s/ê//g s/ë//g s/ì//g s/í//g s/î//g s/ï//g s/ð//g s/ñ//g s/ò//g s/ó//g s/ô//g s/õ//g s/ö//g s/÷//g s/ø//g s/ù//g s/ü//g s/û//g s/ú//g s/ý//g s/þ//g s/ÿ//g s/À//g s/Á//g s/Â//g s/Ã//g s/Ä//g s/Å//g s/Æ//g s/Ç//g s/È//g s/É//g s/Ê//g s/Ë//g s/Ì//g s/Í//g s/Î//g s/Ï//g s/Ð//g s/Ñ//g s/Ò//g s/Ó//g s/Ô//g s/Õ//g s/Ö//g s/×//g s/Ø//g s/Ù//g s/Ü//g s/Û//g s/Ú//g s/Ý//g s/Þ//g s/ß//g s/\[\[Atilde]]//g s/\[\[thorn]]//g s/\[\[eth]]//g s/\[\[Eth]]//g s/&iaute;//g ' $1 # awk 'BEGIN { for (i=128;i<256;i++) {printf ("s/\\\\'\''%x/%c/g\n",i,i)}}' rr } index2dir() { sed -e ' s%\(.*\)%\2 ? \1 % ' } eop() { CTRL_I=`$ECHO "\011"` # ^I CTRL_L=`$ECHO "\014"` # ^L sed -e "s/$CTRL_L/\\ /g" | grep -v "^[$CTRL_I ]*-[$CTRL_I ]*[0-9]*[$CTRL_I ]*-[$CTRL_I ]*$" } ABZAC() { CTRL_I=`$ECHO "\011"` # ^I sed -e " s/^$CTRL_I/ / s/^ /\\ / " } abzac() { perl -e 'while(read(STDIN,$_,100000)){s%\n\n%\n%g;print;}' } lyr() { #$song #%text . #%music #%title #%first ... #;%alias #;%theme #%exec @NADEZHDA #%chords 3 #;% - #; - # perl -pe perl -e ' $inzagolowok=0; while() { s/\@ADELUNG/ .H./; s/\@BELETSKY_V/ ./; s/\@PIRATS//; s/\@TOURISM//; s/\@MITYAEV_BRIGHT_PAST/ .../; # if ($_ !~ /^[;%\$@]/) if ($_ !~ /^[%\$@]|^\;%|^\;$/) { if ( $inzagolowok ) { # if ($chords > 0) { $plus=""; } else { $plus="- ";} if (length ($title) < 2) { $title=$first; } if ($music eq $text) { $text=""; } if (length $music && length $text) { $authors="$music, $text"; } else { $authors="$music $text"; } print "\n $plus",$title," \t$authors\n"; $inzagolowok=0;$title="";$first="";$music="";$text=""; } print; } else { $inzagolowok=1; #s/^%exec.*// ; #s/^\;.*// ; #s/^\$song\n// ; /^%chords *(\d*)/ && do {$chords=$1;}; /^%text *(.*)/ && do { $text=$1;}; /^%music *(.*)/ && do { $music=$1;}; /^%first *(.*)/ && do { $first=$1;}; /^%title *(.*)/ && do { $title=$1;}; } } ' } aksrus() { # tr "_XxVv:;hH'"'"'"?Ww%[*@=" '\-"":?!NR' | KOI -rus } fromhex() { perl -e ' while() { s/0x([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; print; } ' 2> /dev/null } ASC() { perl -e 'while(read(STDIN,$_,1000000)) { tr%\t% %; s%([\n\r\t ]*)([iub]>)%$2$1%sig ; s%(<[ibu]>)([\n\r\t ]*)%$2$1%sig ; s%( *)%$1%ig;s%( *)%$1%ig;s%( *)%$1%ig; print;}' |\ perl -e ' while() { tr/\001\222\223\224''\204/\047\"\"\"\"\"/; # "" s%( *)%$1%ig;s%( *)%$1%ig; tr/\237\240\232\r/ \n/; s/\205/.../g; s/\037//g; s/[\227\226]/--/g; s/\200"/--/g; s/"--/No/g; s/?/No/g; print; } ' 2> /dev/null } LEX() { perl -e ' while() { s/_([^]*)0/$1/g; s/1([^]*)0/$1/g; s/2([^]*)0/$1/g; s/[_0-2]([^\n]*)$/$1/g; print; } ' 2> /dev/null } ANS() { # Save as text with layout # - # 8- . perl -e ' while() { tr/\222\223\224/\047\"\"/; # "" s/\205/.../g; s/\227/--/g; s/\226/--/g; if ( $_ =~ /^( *[a-z`\|{~@}]*)(.*)/i ) { $a=$1; $c=$1 ; $b=$2 ; $a =~ tr/@ABWGDEVZIJKLMNOPRSTUFHC+{}YX|~Qabwgdevzijklmnoprstufhc=\133\135Ryx\\`q?/RR?/; print "$a$b\n" ;} else { print ; } } ' 2> /dev/null } CT1CU() { # . # # CTRL_T=`$ECHO "\024"` # ^T CTRL_U=`$ECHO "\025"` # ^U sed -e ' s/^ *\([0-9][0-9]*\)$/ '"$CTRL_T"'\1'"$CTRL_U"'/ ' } psewdo() { # KOI -rk2pcl | KOI -a | KOI -psewdo - - alt- perl -e ' while() { s/\203\201/\332/g; s/\203\202/\277/g; s/\203\203/\300/g; s/\203\204/\331/g; s/\203\205/\302/g; s/\203\206/\264/g; s/\203\207/\303/g; s/\203\210/\301/g; s/\203\211/\305/g; s/\203\212/\263/g; s/\203\213/\304/g; s/\203\214/\302/g; s/\203\215/\264/g; s/\203\216/\303/g; s/\203\217/\301/g; s/\203\220/\263/g; s/\203\221/\311/g; s/\203\222/\273/g; s/\203\223/\310/g; s/\203\224/\274/g; s/\203\225/\313/g; s/\203\226/\271/g; s/\203\227/\314/g; s/\203\230/\312/g; s/\203\231/\316/g; s/\203\232/\272/g; s/\203\233/\315/g; s/\205\201/\263/g; s/\205\202/\304/g; s/\205\203/\263/g; s/\205\204/\304/g; s/\205\205/\272/g; s/\205\206/\315/g; s/\205\207/\272/g; s/\205\210/\315/g; s/\205\213/\307/g; s/\205\215/\321/g; s/\205\216/\266/g; s/\205\217/\307/g; s/\205\220/\317/g; s/\205\225/\330/g; s/\205\226/\327/g; s/\205\227/\265/g; s/\205\230/\267/g; s/\205\231/\270/g; s/\205\232/\275/g; s/\205\233/\276/g; s/\205\234/\306/g; s/\205\235/\320/g; s/\205\236/\322/g; s/\205\237/\323/g; # s/\205\241/\324/g; s/\205\263/\324/g; s/\205\242/\325/g; s/\205\243/\326/g; print; } ' 2> /dev/null } PERENOS() { perl -e 'while(read(STDIN,$_,512000)){s/([^-])-\n/$1/sg;print;}' } preformat() { perl -e ' while() { s/ - / == /g; s/([ ,!.?])-{1,2}/$1==/g; s/^-{1,2}([^-])/== $1/; s/ -$/ ==/; s/^ /\n /; print; } ' } PREFORMAT() { perl -e ' while() { s/^==([^=])/--$1/g; s/([^=])==$/$1--/g; s/([^=])==([^=])/$1--$2/g; print; } ' | perl -e 'while(read(STDIN,$_,100000)){s%\n\n%\n%g;print;}' } wfor() { perl -e 'while(){s/^[ \t]*/\n /;print;}' } PRUD() { tr "\217?\214\232'-???\221R?ſ?\215\201\225?\210\212\203\237\202\227\216\204\220\207\222\200" "R" } HRAM() { tr "'' '???????" " " } hlebnikow() { sed -e ' s%%% s%]*>%% s%]*>%% s% FACE=[^>]*%% s% SIZE=[123]%% s%%% ' } MAN() { # Convertor abs-book.txt NROFF formatted to HTML H=`echo -e "\010"` T=`echo -e "\024"` U=`echo -e "\025"` Q=`echo -e "\021"` R=`echo -e "\022"` sed -e " s/_$H\(.\)/$T\1$U/g s/$U$T//g s/$U\( *\)$T/\1/g s%.$H\(.\)%$Q\1$R%g s/$R$Q//g s/$R\( *\)$Q/\1/g s/\</g s%$Q%%g s%$R%%g " } # ? ~/bbs/moshkow.txt NA2() { LC_CTYPE=C export LC_CTYPE tr '\n' ' ' | perl -e ' while(read(STDIN,$_,1000000)){ # s%.*%%i; s%]*]*>%%i; s%?html>%%i; s%%%i; s%\002%*%g; s% % %gi; s%<(p|br|div) [^>]*>%<$1>%gi; s% (face|size) *= *"[^"]*"%%gi; s%(.*?)%$1%gi; s%?b>( *)?b>%$1%gi; s%?u>( *)?u>%$1%gi; s%?i>( *)?i>%$1%gi; s%( +)([iub])>%$2>$1%sgi; # s%\023 +XE +".*?" +\025%%sg; # s%%\n %sgi; s%%\n\n %sgi; print; } ' } # - NA3() { LC_CTYPE=C export LC_CTYPE perl -e ' while(<>){ s%^ (.*)$% \024$1\025%i; print; } ' } NA() { LC_ALL=C LC_CTYPE=C export LC_CTYPE egrep -via 'charset=windows-12|meta http-equiv="Content-Type"' |\ perl -e ' while(){ s%]*>%% ; s% FACE="[A-Za-z, ]+"%%ig ; s% FACE=[^"> ,]*?%%ig ; s% SIZE=[12]%%ig ; s%<(p|b|i|div|br) .*?>%<$1>%ig ; s% % %ig; print; }' exit } NAB() { LC_ALL=C LC_CTYPE=C export LC_CTYPE # egrep -vi 'charset=windows-12|meta http-equiv="Content-Type"' ; exit egrep -v '^*HTML>$|^*HEAD>$|text/html; charset=windows-125' |\ perl -e 'while(read(STDIN,$_,100000)) {s%([^\n]{980,})!\n%$1%g; s%!\n!\n!\n!\n%%g;s%!\n!\n!\n%%g;s%!\n!\n%%g; s%!\n( *[-])%$1%g; s%\n(size=[-0-9]+)% $1%ig;print;}' |\ perl -e ' while(){ s%]*>\n%% ; s%]*>\n%% ; s%*BODY[^>]*>%% ; s%\227% %g; s%—%--%g ; s% % %g; s%“%"%g; s%”%"%g; s% %%g; s%['']%"%g ; s% SIZE="[-0-9]+"%%ig ; s% SIZE=[-+0-9]+%%ig ; s% FACE="[A-Za-z ]+"%%ig ; s% FACE="?[^"> ]*"?%%ig ; s% COLOR="[^"]*"%%ig ; s%^%\n %i ; s%%\n\n %ig ; s%%\n\n %ig ; s%\n%\n %igs; s%%\n %ig ; s%%\n %ig ; s%?FONT>%%ig ; s%?DIR>%%ig ; s%%\n %ig ; s%%%ig ; s%^([^<]*)% $1%g; s%--%-- %g ; s%"%"%ig ; print ; } ' |\ perl -e 'while(read(STDIN,$_,100000)) {s%(<[bi]>)([ \n]+)%$2$1%ig; s%([ \n]+)([bi]>)%$2$1%ig; print;}' } SKRIZHALI() { LC_ALL=C LC_CTYPE=C export LC_CTYPE perl -e ' while(){ s% SIZE="[0-9]*"%%ig ; s% SIZE=[0-9]*%%ig ; s% COLOR="[^"]*"%%ig ; s% FACE="[^"]*"%%ig ; s%%%ig ; s%%%ig ; print ; } ' } OTSTUP() { sed -e 's/^[ ][ ]*/ /' |\ perl -e 'while(read(STDIN,$_,100000)){ s%\n\n([^\n ])%\n\n $1%g; print;}' } OTSTUP2() { MINSIZE=56 sed -e 's/^[ ][ ]*/ /' |\ perl -e 'while(read(STDIN,$_,100000)){ s%\n-%\n -%g; s%\n([^\n]{0,'"$MINSIZE"'})\n%\n$1\n %g; print;}' } wyazh() { tmp=/tmp/$$mm cat $1 |\ egrep -v '*HTML>|*HEAD>|*BODY' |\ tr '[A-Z]' '[a-z]' |\ sed -e ' s% % % s%%\ \ %' > $tmp } WWID() { perl -e 'while(read(STDIN,$_,100000)){ s/\[Author.*?\]//sgi; print;}' } WW() { tmp=/tmp/ww$$.doc trap "rm -f $tmp" 0 1 2 3 9 10 15 cat > $tmp if file $tmp | grep "Rich Text Format" > /dev/null 2> /dev/null ; then rtf2html $tmp| KOI -W |KOI -ASC |KOI -MSHTML | KOI -NA | KOI -NA2 |KOI -NOHTMLIB |KOI -OTSTUP|KOI -FORMAT|KOI -ASC |KOI -NA3|KOI -PREFORMAT else # if egrep -i 'microsoft word' $tmp > /dev/null # then # mswordview -o moshkow.txt LD_LIBRARY_PATH=/usr/local/lib wvHtml --charset=windows-1251 $tmp - |\ KOI -W |KOI -ASC |KOI -MSHTML |KOI -NA |KOI -NA2 |KOI -NOHTMLIB|KOI -ASC|KOI -ASC | KOI -WWID | KOI -OTSTUP |KOI -FORMAT|KOI -NA3|KOI -PREFORMAT|KOI -PREFORMAT # else # winword $tmp # for flag in -W -ASC -wfor -FORMAT -PREFORMAT ; do # KOI $flag moshkow.txt moshkow.txt # done # beep # fi fi } WWC() { tmp=/tmp/ww$$.doc trap "rm -f $tmp" 0 1 2 3 9 10 15 cat > $tmp if file $tmp | grep "Rich Text Format" > /dev/null 2> /dev/null ; then rtf2html $tmp| KOI -W |KOI -ASC |KOI -MSHTML | KOI -NA # | KOI -NA2 |KOI -NOHTMLIB | sed -e 's/^ //' -e 's/ *$//' else LD_LIBRARY_PATH=/usr/local/lib wvHtml --charset=windows-1251 $tmp - |\ KOI -W |KOI -ASC |KOI -MSHTML |KOI -NA # |KOI -NA2 |KOI -NOHTMLIB | KOI -OTSTUP |KOI -FORMAT|KOI -NA3|KOI -PREFORMAT|KOI -PREFORMAT fi } UTF8() { utf8 |\ perl -e ' while (<>){ s/]*src="?file[^>]*>//gi; s///gi; s/['']/"/gi; s/\200[\234\235]/"/gi; s/\200\224/--/gi; s/\200?//gi; s/\200[\236]/.../gi; s/\200\231/'"'"'/gi; last if /Document converted from word/; print; } ' true perl -e ' while(1) { break if (!read(STDIN,$C,1)); $I = $C-0320; if( $I == 0 || $I == 1 ) { # , read(STDIN,$C,1); if( $I == 0 ) { if( $C >= 0220 && $C < 0300 ) {$C = $C-0220+0300;} } else { if ( $C >= 0200 ) { $C = $C+0160; } } } print $C; } ' } FORMAT() { LC_ALL=C LC_CTYPE=C formater.pl | sed 's/^ *$//' } SH() { CTRL_T=`$ECHO "\024"` # ^T CTRL_U=`$ECHO "\025"` # ^U egrep -v '^ *WWW: *$' |\ sed -e " s/WWW: *\([^| ]*\) *$/WWW: \1 | \1/; s/|/?/; s/^ *\^[T]/ $CTRL_T/; s/\^U/$CTRL_U/; " } AHREF() { sed -e 's%\(ftp://[-a-z0-9/_.~]*\)%\1% s%\(http://[-:a-zA-Z0-9/_.~]*\)%\1%' } AKM() { perl -e 'while(read(STDIN,$_,100000)){ s%.*?%%sgi; s%.*?%%sgi; # .* - $MOSHKOWENCODING=< koi win lat iso alt mac rema.ru/akm EOF s%%$MOSHKOWENCODING%sio; print; }' } mime() { perl -e 'while(read(STDIN,$_,100000)){ s/([^0-9 A-Za-z])/sprintf("%%%02X",unpack("C", $1))/seg; print; }' } UNIW() { # # А П Я - 1040 + 192 # # а п я perl -e 'while(read(STDIN,$_,100000)){ s/\&\#(\d+)\;/pack("C", $1 - 848 )/seg; print "$_"; }' | KOI -W } uniw() { # # А П Я - 1040 + 192 # # а п я perl -e 'while(read(STDIN,$_,100000)){ s/([\300-\377])/sprintf("%d",848+unpack("C", $1))/seg; print "$_"; }' } SX1() # UNICODE SX1: abc -- > ^@b^@c^@,- -> 0^D1^D-N^DO^D { perl -e ' sub rec{$c=unpack("C",@_[0]); if (@_[1] eq "\04"){ if(16 <= $c && $c <= 79 ){return sprintf ("%c",$c+176);} else{ return @_[0]; } }else{ return @_[0]; } } while(read(STDIN,$_,100000)){ s/^//; s/(.)(.)/&rec($1,$2)/seg; print "$_"; }' } sx1() { perl -e ' sub rec{(192<=($c=unpack(C,@_[0])))?pack(C,$c-176)."\04":@_[0]."\0";} print ""; while(<>){ s/./&rec($&)/seg; print $_; }' } utf8n() { # ? ../linlocal/C/utf8.c perl -e ' sub rec{(($c=unpack(C,@_[0]))<0360)?pack(C2,0320,$c-060):pack(C2,0321,$c-0160)} while(<>){s/[\300-\377]/&rec($&)/seg;print;} ' } MIME() { perl -e 'while(read(STDIN,$_,100000)){ s/[%=]([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/seg; print; }' } oct() { perl -e 'while(read(STDIN,$_,100000)){ s/(.)/sprintf("\\%03o",unpack("C", $1))/seg; print; }' } oTSTUP() { sed -e " s/^ *\([$malenxkie]\)/\1/ s/^ *- \([$malenxkie]\)/- \1/ " } KRU() { KOI -ASC |\ perl -e ' while(<>){ s/@@@/?/; s%^\s*/###\s*(.*)\s*###/% \024 * $1 * \025%; s%^\s*###\s*(.*)\s*###% \024$1\025%; print; } ' } LIB() { perl -e 'while(read(STDIN,$_,100000)){ s%\n\n%\n-----------------------------------------------------------\n%sgi; s%.*1%%; s%%\n \024%sgi; s%%\n \024%sgi; s%%\025%sgi; s%%\025%sgi; s%Last-modified:.*%%s; print ; } ' } TU() { perl -e 'while(read(STDIN,$_,100000)){ unless ($n){s/^\s*/ /s;} s/\^T/\024/sg; s/\^U/\025/sg; s//\025/sg; s//\n \024/sg; print; $n++;}' } TEXTSHARE() { perl -e 'while (read(STDIN,$_,500000)){ s/\n(--+)\n( +\(.*?\n)*/\n\n $&\n\n/sg; s/\[\d+\]\n//sg; s/([^-])-\n([^\n])/$1$2/sg; print; }' 2> /dev/null } SORT() { KOI -a|sort|KOI -A } REABZAC() { perl -e 'while (read(STDIN,$_,500000)){ s/-\n ([])/$1/g; s/\n ([])/ $1/g; print; } ' } LINE() { perl -e 'while (read(STDIN,$_,500000)){ s/\n([^ \n])/ $1/g; s/([^ \n]) +/$1 /g; print; } ' } MSHTML() { perl -e ' while (read (STDIN,$_,3000000)){ s%%%sg; s% name=\".+?\"%%gsi; s%?(o|w):.*?>%%sgi; # s%]*>.*?]*>%%sgi; # s%]*>.*?]*>%%sgi; s%<\!.*?>%%sgi; s%<(p|b|div|br) .*?>%<$1>%sgi; s%%%sgi; s% style='\''.*?'\''%%sgi; s%(span|p)>%%sgi; s%—%--%sgi; s%…%...%sgi; s%&[lr]dquo;%"%sgi; s%"%"%sgi; s%%%sgi; print; } ' } NOHTML() { perl -e 'while (read (STDIN,$_,1000000)){s%<.*?>%%sg;print;}' } NOHTMLIB() { perl -e ' while (read (STDIN,$_,1000000)) { s%<(/?[ib])>%{$1}%sgi; s%<(/?(table|tr|td)).*?>%{$1}%sgi; s%<(/?sup)>%{$1}%sgi; s%<(li)>%{$1}%sgi; s%<(img .*?)>%{$1}%sgi; s%(.*?)%\n \024$1\025\n%sgi; s%<.*?>%%sg; s%\{(/?[ib])\}%<$1>%sgi; s%\{(/?sup)\}%<$1>%sgi; s%\{(li)\}% <$1>%sgi; s%\{(img .*?)\}%<$1>%sgi; s%\{(/?(table|tr|td)).*?\}%<$1>%sgi; print; } ' } UTFHTML() { sed -e ' s/Ô//g; s/Æ//g; s/Ø//g; s/Ý//g; s/Õ//g; s/Ó//g; s/×//g; s/ú//g; s/Ð//g; s/Ë//g; s/Å//g; s/Ä//g; s/À//g; s/Á//g; s/Ç//g; s/Ò//g; s/ô//g; s/ß//g; s/Ê//g; s/Í//g; s/Â//g; s/Ã//g; s/Ì//g; s/Ñ//g; s/Ï//g; s/Î//g; s/ý//g; s/ù//g; s/È//g; s/ö//g; s/þ//g; s/ø//g; s/õ//g; s/æ//g; s/é//g; s/÷//g; s/á//g; s/û//g; s/ç//g; s/ã//g; s/ÿ//g; s/ü//g; s/ï//g; s/ì//g; s/ó//g; s/ä//g; s/ê//g; s/ð//g; s/ë//g; s/â//g; s/ñ//g; s/ò//g; s/è//g; s/í//g; s/à//g; s/å//g; s/î//g; s/ / /g; ' } UTFNUM() { sed -e ' s/ / /g; s/¸/e/g; s/À//g; s/Á//g; s/Â//g; s/Ã//g; s/Ä//g; s/Å//g; s/Æ//g; s/Ç//g; s/È//g; s/É//g; s/Ê//g; s/Ë//g; s/Ì//g; s/Í//g; s/Î//g; s/Ï//g; s/Ð//g; s/Ñ//g; s/Ò//g; s/Ó//g; s/Ô//g; s/Õ//g; s/Ö//g; s/×//g; s/Ø//g; s/Ù//g; s/Ú//g; s/Û//g; s/Ü//g; s/Ý//g; s/Þ//g; s/ß//g; s/à//g; s/á//g; s/â//g; s/ã//g; s/ä//g; s/å//g; s/æ//g; s/ç//g; s/è//g; s/é//g; s/ê//g; s/ë//g; s/ì//g; s/í//g; s/î//g; s/ï//g; s/ð//g; s/ñ//g; s/ò//g; s/ó//g; s/ô//g; s/õ//g; s/ö//g; s/÷//g; s/ø//g; s/ù//g; s/ú//g; s/û//g; s/ü//g; s/ý//g; s/þ//g; s/ÿ//g; ' } getmail=' [ -d ~moshkow/mmm ] || exit 1 cd /var/spool/mqueue /etc/rc.d/rc3.d/S80sendmail stop ; sleep 3 ; /etc/rc.d/rc3.d/S80sendmail stop ; sleep 3 ; /etc/rc.d/rc3.d/S80sendmail stop grep -lq moshkow q* | sed "s/^.//" | while read f ; do mv q$f d$f ~moshkow/mmm/ ; done cd ~moshkow/mmm tar czvf ~/mail.tgz * ls -al ~/mail.tgz /etc/rc.d/rc3.d/S80sendmail start ' LADA() { KOI -W|KOI -ASC|KOI -ASC|KOI -wfor|KOI -FORMAT|KOI -PREFORMAT } KW() { tmp=/tmp/ww$$.doc trap "rm -f $tmp" 0 1 2 3 9 10 15 cat > $tmp cd cd bbs kword $tmp ; # mv $tmp ~/bbs/moshkow.txt mv ~/bbs/aa ~/bbs/moshkow.txt for flag in -UTF8 -W -ASC -NA -NA2 -NAB -OTSTUP -FORMAT -NA3 -PREFORMAT; do KOI $flag moshkow.txt moshkow.txt done } WH() { KOI -M|KOI -ASC |KOI -MSHTML|KOI -ASC|KOI -NA|KOI -NAB|KOI -NOHTMLIB|KOI -ASC|KOI -OTSTUP|KOI -FORMAT|KOI -PREFORMAT } WHC() { KOI -ASC |KOI -MSHTML|KOI -ASC|sed 's/^ *//'|KOI -NA|KOI -NAB|KOI -NOHTMLIB|KOI -OTSTUP|KOI -FORMAT|KOI -PREFORMAT } RTF() { perl -e ' while (read (STDIN,$_,1000000)) { #s/\r//sg; s/\\\r\n/\n/sg; s/\\cf\d//sg; s%\{\\([a-z]+)\d*(.*?)\}%<$1>\{$2\}$1>%sg; s%\{\\([a-z]+)\d*(.*?)\}%<$1>\{$2\}$1>%sg; s%\{\\([a-z]+)\d*(.*?)\}%<$1>\{$2\}$1>%sg; s%\\([ib])0%$1>%sg; s/\\([ib])/<$1>/sg; s/\\q\w//sg; s/\\pard/\n\n/sg; s/\\emdash/--/sg; s/\\~/ /sg; s/[{}]//sg; print; }' } if [ -z "$2" ] ; then $CAT $1 | $TRANSLATOR $FROM $INTO | $UNIXORDOS else if [ "$1" = "$2" ] then TMP=/tmp/koi$$ $CAT "$1" | $TRANSLATOR $FROM $INTO | $UNIXORDOS > $TMP ; touch -r "$1" $TMP # mv -f $TMP $2 || ( cp -f $TMP $2 && rm $TMP ) else $CAT "$1" | $TRANSLATOR $FROM $INTO | $UNIXORDOS > "$2" fi fi exit
%\n\n %sgi; print; } ' } # - NA3() { LC_CTYPE=C export LC_CTYPE perl -e ' while(<>){ s%^ (.*)$% \024$1\025%i; print; } ' } NA() { LC_ALL=C LC_CTYPE=C export LC_CTYPE egrep -via 'charset=windows-12|meta http-equiv="Content-Type"' |\ perl -e ' while(){ s%]*>%% ; s% FACE="[A-Za-z, ]+"%%ig ; s% FACE=[^"> ,]*?%%ig ; s% SIZE=[12]%%ig ; s%<(p|b|i|div|br) .*?>%<$1>%ig ; s% % %ig; print; }' exit } NAB() { LC_ALL=C LC_CTYPE=C export LC_CTYPE # egrep -vi 'charset=windows-12|meta http-equiv="Content-Type"' ; exit egrep -v '^*HTML>$|^*HEAD>$|text/html; charset=windows-125' |\ perl -e 'while(read(STDIN,$_,100000)) {s%([^\n]{980,})!\n%$1%g; s%!\n!\n!\n!\n%%g;s%!\n!\n!\n%%g;s%!\n!\n%%g; s%!\n( *[-])%$1%g; s%\n(size=[-0-9]+)% $1%ig;print;}' |\ perl -e ' while(){ s%]*>\n%% ; s%]*>\n%% ; s%*BODY[^>]*>%% ; s%\227% %g; s%—%--%g ; s% % %g; s%“%"%g; s%”%"%g; s% %%g; s%['']%"%g ; s% SIZE="[-0-9]+"%%ig ; s% SIZE=[-+0-9]+%%ig ; s% FACE="[A-Za-z ]+"%%ig ; s% FACE="?[^"> ]*"?%%ig ; s% COLOR="[^"]*"%%ig ; s%^%\n %i ; s%%\n\n %ig ; s%%\n\n %ig ; s%\n%\n %igs; s%%\n %ig ; s%%\n %ig ; s%?FONT>%%ig ; s%?DIR>%%ig ; s%%\n %ig ; s%
%\n %i ; s%
%\n\n %ig ; s%
Last-modified:.*%%s; print ; } ' } TU() { perl -e 'while(read(STDIN,$_,100000)){ unless ($n){s/^\s*/ /s;} s/\^T/\024/sg; s/\^U/\025/sg; s//\025/sg; s//\n \024/sg; print; $n++;}' } TEXTSHARE() { perl -e 'while (read(STDIN,$_,500000)){ s/\n(--+)\n( +\(.*?\n)*/\n\n $&\n\n/sg; s/\[\d+\]\n//sg; s/([^-])-\n([^\n])/$1$2/sg; print; }' 2> /dev/null } SORT() { KOI -a|sort|KOI -A } REABZAC() { perl -e 'while (read(STDIN,$_,500000)){ s/-\n ([])/$1/g; s/\n ([])/ $1/g; print; } ' } LINE() { perl -e 'while (read(STDIN,$_,500000)){ s/\n([^ \n])/ $1/g; s/([^ \n]) +/$1 /g; print; } ' } MSHTML() { perl -e ' while (read (STDIN,$_,3000000)){ s%%%sg; s% name=\".+?\"%%gsi; s%?(o|w):.*?>%%sgi; # s%]*>.*?]*>%%sgi; # s%]*>.*?]*>%%sgi; s%<\!.*?>%%sgi; s%<(p|b|div|br) .*?>%<$1>%sgi; s%%%sgi; s% style='\''.*?'\''%%sgi; s%(span|p)>%%sgi; s%—%--%sgi; s%…%...%sgi; s%&[lr]dquo;%"%sgi; s%"%"%sgi; s%%%sgi; print; } ' } NOHTML() { perl -e 'while (read (STDIN,$_,1000000)){s%<.*?>%%sg;print;}' } NOHTMLIB() { perl -e ' while (read (STDIN,$_,1000000)) { s%<(/?[ib])>%{$1}%sgi; s%<(/?(table|tr|td)).*?>%{$1}%sgi; s%<(/?sup)>%{$1}%sgi; s%<(li)>%{$1}%sgi; s%<(img .*?)>%{$1}%sgi; s%(.*?)%\n \024$1\025\n%sgi; s%<.*?>%%sg; s%\{(/?[ib])\}%<$1>%sgi; s%\{(/?sup)\}%<$1>%sgi; s%\{(li)\}% <$1>%sgi; s%\{(img .*?)\}%<$1>%sgi; s%\{(/?(table|tr|td)).*?\}%<$1>%sgi; print; } ' } UTFHTML() { sed -e ' s/Ô//g; s/Æ//g; s/Ø//g; s/Ý//g; s/Õ//g; s/Ó//g; s/×//g; s/ú//g; s/Ð//g; s/Ë//g; s/Å//g; s/Ä//g; s/À//g; s/Á//g; s/Ç//g; s/Ò//g; s/ô//g; s/ß//g; s/Ê//g; s/Í//g; s/Â//g; s/Ã//g; s/Ì//g; s/Ñ//g; s/Ï//g; s/Î//g; s/ý//g; s/ù//g; s/È//g; s/ö//g; s/þ//g; s/ø//g; s/õ//g; s/æ//g; s/é//g; s/÷//g; s/á//g; s/û//g; s/ç//g; s/ã//g; s/ÿ//g; s/ü//g; s/ï//g; s/ì//g; s/ó//g; s/ä//g; s/ê//g; s/ð//g; s/ë//g; s/â//g; s/ñ//g; s/ò//g; s/è//g; s/í//g; s/à//g; s/å//g; s/î//g; s/ / /g; ' } UTFNUM() { sed -e ' s/ / /g; s/¸/e/g; s/À//g; s/Á//g; s/Â//g; s/Ã//g; s/Ä//g; s/Å//g; s/Æ//g; s/Ç//g; s/È//g; s/É//g; s/Ê//g; s/Ë//g; s/Ì//g; s/Í//g; s/Î//g; s/Ï//g; s/Ð//g; s/Ñ//g; s/Ò//g; s/Ó//g; s/Ô//g; s/Õ//g; s/Ö//g; s/×//g; s/Ø//g; s/Ù//g; s/Ú//g; s/Û//g; s/Ü//g; s/Ý//g; s/Þ//g; s/ß//g; s/à//g; s/á//g; s/â//g; s/ã//g; s/ä//g; s/å//g; s/æ//g; s/ç//g; s/è//g; s/é//g; s/ê//g; s/ë//g; s/ì//g; s/í//g; s/î//g; s/ï//g; s/ð//g; s/ñ//g; s/ò//g; s/ó//g; s/ô//g; s/õ//g; s/ö//g; s/÷//g; s/ø//g; s/ù//g; s/ú//g; s/û//g; s/ü//g; s/ý//g; s/þ//g; s/ÿ//g; ' } getmail=' [ -d ~moshkow/mmm ] || exit 1 cd /var/spool/mqueue /etc/rc.d/rc3.d/S80sendmail stop ; sleep 3 ; /etc/rc.d/rc3.d/S80sendmail stop ; sleep 3 ; /etc/rc.d/rc3.d/S80sendmail stop grep -lq moshkow q* | sed "s/^.//" | while read f ; do mv q$f d$f ~moshkow/mmm/ ; done cd ~moshkow/mmm tar czvf ~/mail.tgz * ls -al ~/mail.tgz /etc/rc.d/rc3.d/S80sendmail start ' LADA() { KOI -W|KOI -ASC|KOI -ASC|KOI -wfor|KOI -FORMAT|KOI -PREFORMAT } KW() { tmp=/tmp/ww$$.doc trap "rm -f $tmp" 0 1 2 3 9 10 15 cat > $tmp cd cd bbs kword $tmp ; # mv $tmp ~/bbs/moshkow.txt mv ~/bbs/aa ~/bbs/moshkow.txt for flag in -UTF8 -W -ASC -NA -NA2 -NAB -OTSTUP -FORMAT -NA3 -PREFORMAT; do KOI $flag moshkow.txt moshkow.txt done } WH() { KOI -M|KOI -ASC |KOI -MSHTML|KOI -ASC|KOI -NA|KOI -NAB|KOI -NOHTMLIB|KOI -ASC|KOI -OTSTUP|KOI -FORMAT|KOI -PREFORMAT } WHC() { KOI -ASC |KOI -MSHTML|KOI -ASC|sed 's/^ *//'|KOI -NA|KOI -NAB|KOI -NOHTMLIB|KOI -OTSTUP|KOI -FORMAT|KOI -PREFORMAT } RTF() { perl -e ' while (read (STDIN,$_,1000000)) { #s/\r//sg; s/\\\r\n/\n/sg; s/\\cf\d//sg; s%\{\\([a-z]+)\d*(.*?)\}%<$1>\{$2\}$1>%sg; s%\{\\([a-z]+)\d*(.*?)\}%<$1>\{$2\}$1>%sg; s%\{\\([a-z]+)\d*(.*?)\}%<$1>\{$2\}$1>%sg; s%\\([ib])0%$1>%sg; s/\\([ib])/<$1>/sg; s/\\q\w//sg; s/\\pard/\n\n/sg; s/\\emdash/--/sg; s/\\~/ /sg; s/[{}]//sg; print; }' } if [ -z "$2" ] ; then $CAT $1 | $TRANSLATOR $FROM $INTO | $UNIXORDOS else if [ "$1" = "$2" ] then TMP=/tmp/koi$$ $CAT "$1" | $TRANSLATOR $FROM $INTO | $UNIXORDOS > $TMP ; touch -r "$1" $TMP # mv -f $TMP $2 || ( cp -f $TMP $2 && rm $TMP ) else $CAT "$1" | $TRANSLATOR $FROM $INTO | $UNIXORDOS > "$2" fi fi exit