#!/bin/sh
# EBCDIC to ISO Latin 1 conversion
# Usage: ebcdic2iso [-37|-500] [files]
# Flags specify which IBM Code Page to use, 37 is default
#  37 uses BA (\272) and BB (\273) for [], 5A (\132) for !, 4F (\117) for |
# 500 uses 4A (\112) and 5A (\132) for [], 4F (\117) for !, BB (\273) for |
# There are other difference involving ^,  and 
# I'm not sure about hex 41, which I've given as \240 (NBSP)
# I've translated the unused EBCDIC characters (0-1F, FF) straight across,
# but moved the characters 20-3F to the unused \200-\237
cp="\242\174\041\254\136\133\135"
case $1 in
  -37) shift ;;
  -500) cp="\133\041\135\136\242\254\174"; shift ;;
  -*) echo "Usage: ebcdic2iso [-37|-500] [files]" 1>&2; exit 1 ;;
esac
cat $@ |
tr "\040-\077\100-\111\113-\116\120-\131\133-\136\140-\257\261-\271\274-\376\112\117\132\137\260\272\273" "\200-\237\040\240\342\344\340\341\343\345\347\361\056\074\050\053\046\351\352\353\350\355\356\357\354\337\044\052\051\073\055\057\302\304\300\301\303\305\307\321\246\054\045\137\076\077\370\311\312\313\310\315\316\317\314\140\072\043\100\047\075\042\330\141\142\143\144\145\146\147\150\151\253\273\360\375\376\261\260\152\153\154\155\156\157\160\161\162\252\272\346\270\306\244\265\176\163\164\165\166\167\170\171\172\241\277\320\335\336\256\243\245\267\251\247\266\274\275\276\255\250\264\327\173\101\102\103\104\105\106\107\110\111\257\364\366\362\363\365\175\112\113\114\115\116\117\120\121\122\271\373\374\371\372\377\134\367\123\124\125\126\127\130\131\132\262\324\326\322\323\325\060\061\062\063\064\065\066\067\070\071\263\333\334\331\332$cp"



