#!/bin/sh
#
#  This is a part of ChiTeX.
#  This script is created by 
#    Hung-Yih Chen ()  (yih@math.ncu.edu.tw)
#               (Dept. of Mathematics, National Central Univ.)
#  Last revised on Nov. 22, 2000
# 
#                All rights preserved   
#

#filea=`echo $1|cut -d. -f 1` 

/bin/rm -f tmp@.* tmp@ tmp@.tex temp@idx tmp@mac

#export LC_CTYPE=zh_TW.Big5

export LC_ALL=C

echo "y" > tmp@


gawkbin="gawk"
#gawkbin="awk"

searchtexmf="y"
if test "$searchtexmf" = "y"; then
texmfcnffile=`kpsexpand -w cnf texmf.cnf`
TEXMFCNF=`
$gawkbin  '
{texmfcnfloc=index(texmfcnffile,"/texmf.cnf")
 print substr(texmfcnffile,1,texmfcnfloc-1)
}' texmfcnffile=$texmfcnffile tmp@ `

echo $TEXMFCNF > tmp@
TEXMF=`
$gawkbin '
{
  inline=$0
  gsub(/web2c/,"",inline)
  inline=substr(inline,1,length(inline)-1)
  print inline
}' tmp@ `
fi

texmffile=`kpsexpand '$TEXMFDIST' `
if test "$texmffile" != ""; then
#TEXMF=` gawk '
TEXMFDIR=` $gawkbin '
   {lbr=index(texmffile,"{")
    sep=index(texmffile,",")
    dash=index(texmffile,"-")
    texmfpre=substr(texmffile,1,dash)
    if (lbr > 0)
       {texlive=substr(texmffile,lbr+1,sep-lbr-1) 
        texmf =texmfpre texlive
       }
    else
       {if (dash > 0)
           {texlive=substr(texmffile,dash+1) 
            texmf =texmfpre texlive
           } 
       }    
    print texmf
   }' texmffile=$texmffile tmp@ `
fi

if test "$TEXMFDIR" != "" -a -d "$TEXMFDIR"; then
   TEXMF=$TEXMFDIR
fi


export TEXMF


/bin/rm -f idxfile@
/bin/rm -f option@
filename=""

$gawkbin -v c1=$1 -v c2=$2 -v c3=$3 -v c4=$4 -v c5=$5 -v c6=$6 -v c7=$7 -v c8=$8 -v c9=$9 '
BEGIN{}
{
  c[1]=c1; c[2]=c2; c[3]=c3;c[4]=c4;c[5]=c5;c[6]=c6
  c[7]=c7; c[8]=c8; c[9]=c9

  for (i=1; i<=9; i++)
    {if (c[10-i] != "")
        {if (i != 9)
          {if (substr(c[10-i-1],1,1) != "-")
              {Fname=c[10-i]
               for (j=1; j<=10-i-1; j++)
                   {option=option " " c[j]} 
               break    
              }     
           else
              {break}   
          } 
         else
          {Fname=c[10-i]; break}      
        }   
    }
  print Fname > "idxfile@"  
  print option > "option@"
}
END{} ' tmp@

  if test -s idxfile@; then
     filename=`cat idxfile@`
  fi

  if test -s option@; then     
     option=`cat option@`
  fi   


if test "$filename" = ""; then
   echo "argument error"
#   makeindex --help
   exit
fi

if test ! -s $filename.tex; then
 if test ! -s $filename; then 
    :
 else
   filename=$filename
 fi
else 
 filename=$filename.tex
fi


echo "yes" > tmp@

newfilename=""
newfilename=`
$gawkbin -v filename=$filename '
{
 llen=length(filename)
 i=1; chinese=0
 for (i;i<=llen;i++)
   {ch=substr(filename,i)
    if (ch > "\240" && ch < "\372")
       {chinese=1; break}
   } 
 if (chinese==1)
    {
     while (getline inline < ".tmp00/texf.tab">0)
      {
       sp=index(inline," ")
       chfilename=substr(inline,1,sp-1)
       if (filename==chfilename)
          {rinline=substr(inline,sp+1)
           newfname=rinline; found=1
          }
      }        
     print newfname
    }
}' tmp@ `  

filea=$filename

if test "$newfilename" != ""; then
   oldfilename=$filea
   bname=`basename $filea `                    
   oldfilea=`echo $bname|cut -d. -f 1` 
   filea=`echo $newfilename|cut -d. -f 1`
else 
   filea=`echo $filea|cut -d. -f 1`
fi


  if test "$filenameext" != "tex" -a "$filenameext" != ""; then
     ext="."$filenameext
  else
     ext=""
  fi

gawkbin="gawk"  
#gawkbin="awk"  
export $gawkbin

Utf=""
if test -s "tmp@mac"; then
     Utf="y"
$gawkbin ' 
BEGIN{
     i=0
     while (getline A < "tmp@mac" >0)
      {
       i=i+1
       sep=index(A,";")
       Mac[i] = substr(A,1,sep-1)
       MacData[i]=substr(A, sep+1)
      }
     Macno=i 
}
{
    A=$0
    indexentry=index(A,"\\indexentry")
    if (indexentry > 0)
      {
       AA=substr(A,indexentry)
       if (indexentry>1)
          {LLine=substr(A,1,indexentry-1)}
       else
          {LLine=""}   
       lbr=index(AA,"{")
       rbr=index(AA,"}")
       inrbr=substr(AA,lbr+1,rbr-lbr-1)
       for (i=1; i<=Macno; i++)
          {if (inrbr == Mac[i])
             {A = LLine substr(AA,1,lbr) MacData[i] substr(AA, rbr)
              break
             } 
          } 
      } 
    print A > "temp@idx"
}
END{} ' $filea.idx


#$filea.idx > /dev/null 2>&1      

#gawk -f /usr/bin/utf2text.awk -v texmf=$TEXMF "temp@idx"

if test "$Utf" = "y"; then
iconv -f UTF-8 -t big5 -o tmp@.tex temp@idx
cp -f $filea.idx $filea.idx@
cp -f "tmp@.tex" $filea.idx 
fi
fi

#echo "Utf=$Utf"


if test "$Utf" = ""; then
echo "Wait!"

mkidx1 $filea.idx

#END{
#} ' gawkbin=$gawkbin $filea.idx  > /dev/null 2>&1 

cp $filea.idx $filea.idx.bak
cp tmp@.iii $filea.idx
fi


#exit

#if test "$StyleFileName" != ""; then
#   makeindex -s $StyleFileName $filea.idx
#else
#   makeindex $filea.idx
#fi   

 
makeindex $option $filea.idx 


if test "$Utf" = "y"; then
#  iconv -f big5 -t UTF-8 -o tmp@.tex $filea.ind
#  cp -f tmp@.tex $filea.ind
#  mv -f $filea.idx@ $filea.idx

:
 else
 
 inlinenew=$filea.ind

$gawkbin ' 

 function ASC(inL){
    if (inL=="\x00"){return 0}  else 
    {if (inL=="\x01"){return 1}  else
    {if (inL=="\x02"){return 2}  else
    {if (inL=="\x03"){return 3}  else
    {if (inL=="\x04"){return 4}  else
    {if (inL=="\x05"){return 5}  else
    {if (inL=="\x06"){return 6}  else
    {if (inL=="\x07"){return 7}  else
    {if (inL=="\x08"){return 8}  else
    {if (inL=="\x09"){return 9}  else
    {if (inL=="\x0A"){return 10} else
    {if (inL=="\x0B"){return 11} else
    {if (inL=="\x0C"){return 12} else
    {if (inL=="\x0D"){return 13} else
    {if (inL=="\x0E"){return 14} else
    {if (inL=="\x0F"){return 15} else
    {if (inL=="\x10"){return 16} else
    {if (inL=="\x11"){return 17} else
    {if (inL=="\x12"){return 18} else
    {if (inL=="\x13"){return 19} else
    {if (inL=="\x14"){return 20} else
    {if (inL=="\x15"){return 21} else
    {if (inL=="\x16"){return 22} else
    {if (inL=="\x17"){return 23} else
    {if (inL=="\x18"){return 24} else
   {if (inL=="\x19"){return 25}  else
   {if (inL=="\x1A"){return 26}  else
   {if (inL=="\x1B"){return 27}  else
   {if (inL=="\x1C"){return 28}  else
   {if (inL=="\x1D"){return 29}  else
   {if (inL=="\x1E"){return 30}  else
   {if (inL=="\x1F"){return 31}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\x20"){return 32}
    else
     {if (inL=="\x21"){return 33}
      else 
      {if (inL=="\x22"){return 34}
       else
       {if (inL=="\x23"){return 35}  
        else
        {if (inL=="\x24"){return 36}
         else
         {if (inL=="\x25"){return 37}
          else
          {if (inL=="\x26"){return 38}
           else 
           {if (inL=="\x27"){return 39}
            else
            {if (inL=="\x28"){return 40}
             else
             {if (inL=="\x29"){return 41}
              else
              {if (inL=="\x2A"){return 42}
               else
               {if (inL=="\x2B"){return 43}
                else
                {if (inL=="\x2C"){return 44}
                 else
                 {if (inL=="\x2D"){return 45}
                  else
                  {if (inL=="\x2E"){return 46}
		   else
		   {if (inL=="\x2F"){return 47}
 		    else
                    {if (inL=="\x30"){return 48}
                     else
		     {if (inL=="\x31"){return 49}
		      else
                      {if (inL=="\x32"){return 50}
		       else
		       {if (inL=="\x33"){return 51}
		        else
		        {if (inL=="\x34"){return 52}
		         else
		         {if (inL=="\x35"){return 53}
		          else
		          {if (inL=="\x36"){return 54}
		           else
		           {if (inL=="\x37"){return 55}
		            else
		            {if (inL=="\x38"){return 56}
		             else
		             {if (inL=="\x39"){return 57}
		              else
		              {if (inL=="\x3A"){return 58}
		               else
		               {if (inL=="\x3B"){return 59}
		                else
		                {if (inL=="\x3C"){return 60}
		                 else
		                 {if (inL=="\x3D"){return 61}
		                  else
		                  {if (inL=="\x3E"){return 62}
		                   else
		                   {if (inL=="\x3F"){return 63}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\x40"){return 64}
    else
     {if (inL=="\x41"){return 65}
      else 
      {if (inL=="\x42"){return 66}
       else
       {if (inL=="\x43"){return 67}  
        else
        {if (inL=="\x44"){return 68}
         else
         {if (inL=="\x45"){return 69}
          else
          {if (inL=="\x46"){return 70}
           else 
           {if (inL=="\x47"){return 71}
            else
            {if (inL=="\x48"){return 72}
             else
             {if (inL=="\x49"){return 73}
              else
              {if (inL=="\x4A"){return 74}
               else
               {if (inL=="\x4B"){return 75}
                else
                {if (inL=="\x4C"){return 76}
                 else
                 {if (inL=="\x4D"){return 77}
                  else
                  {if (inL=="\x4E"){return 78}
		   else
		   {if (inL=="\x4F"){return 79}
 		    else
                    {if (inL=="\x50"){return 80}
                     else
		     {if (inL=="\x51"){return 81}
		      else
                      {if (inL=="\x52"){return 82}
		       else
		       {if (inL=="\x53"){return 83}
		        else
		        {if (inL=="\x54"){return 84}
		         else
		         {if (inL=="\x55"){return 85}
		          else
		          {if (inL=="\x56"){return 86}
		           else
		           {if (inL=="\x57"){return 87}
		            else
		            {if (inL=="\x58"){return 88}
		             else
		             {if (inL=="\x59"){return 89}
		              else
		              {if (inL=="\x5A"){return 90}
		               else
		               {if (inL=="\x5B"){return 91}
		                else
		                {if (inL=="\x5C"){return 92}
		                 else
		                 {if (inL=="\x5D"){return 93}
		                  else
		                  {if (inL=="\x5E"){return 94}
		                   else
		                   {if (inL=="\x5F"){return 95}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\x60"){return 96}
    else
     {if (inL=="\x61"){return 97}
      else 
      {if (inL=="\x62"){return 98}
       else
       {if (inL=="\x63"){return 99}  
        else
        {if (inL=="\x64"){return 100}
         else
         {if (inL=="\x65"){return 101}
          else
          {if (inL=="\x66"){return 102}
           else 
           {if (inL=="\x67"){return 103}
            else
            {if (inL=="\x68"){return 104}
             else
             {if (inL=="\x69"){return 105}
              else
              {if (inL=="\x6A"){return 106}
               else
               {if (inL=="\x6B"){return 107}
                else
                {if (inL=="\x6C"){return 108}
                 else
                 {if (inL=="\x6D"){return 109}
                  else
                  {if (inL=="\x6E"){return 110}
		   else
		   {if (inL=="\x6F"){return 111}
 		    else
                    {if (inL=="\x70"){return 112}
                     else
		     {if (inL=="\x71"){return 113}
		      else
                      {if (inL=="\x72"){return 114}
		       else
		       {if (inL=="\x73"){return 115}
		        else
		        {if (inL=="\x74"){return 116}
		         else
		         {if (inL=="\x75"){return 117}
		          else
		          {if (inL=="\x76"){return 118}
		           else
		           {if (inL=="\x77"){return 119}
		            else
		            {if (inL=="\x78"){return 120}
		             else
		             {if (inL=="\x79"){return 121}
		              else
		              {if (inL=="\x7A"){return 122}
		               else
		               {if (inL=="\x7B"){return 123}
		                else
		                {if (inL=="\x7C"){return 124}
		                 else
		                 {if (inL=="\x7D"){return 125}
		                  else
		                  {if (inL=="\x7E"){return 126}
		                   else
		                   {if (inL=="\x7F"){return 127}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\x80"){return 128}
    else
     {if (inL=="\x81"){return 129}
      else 
      {if (inL=="\x82"){return 130}
       else
       {if (inL=="\x83"){return 131}  
        else
        {if (inL=="\x84"){return 132}
         else
         {if (inL=="\x85"){return 133}
          else
          {if (inL=="\x86"){return 134}
           else 
           {if (inL=="\x87"){return 135}
            else
            {if (inL=="\x88"){return 136}
             else
             {if (inL=="\x89"){return 137}
              else
              {if (inL=="\x8A"){return 138}
               else
               {if (inL=="\x8B"){return 139}
                else
                {if (inL=="\x8C"){return 140}
                 else
                 {if (inL=="\x8D"){return 141}
                  else
                  {if (inL=="\x8E"){return 142}
		   else
		   {if (inL=="\x8F"){return 143}
 		    else
                    {if (inL=="\x90"){return 144}
                     else
		     {if (inL=="\x91"){return 145}
		      else
                      {if (inL=="\x92"){return 146}
		       else
		       {if (inL=="\x93"){return 147}
		        else
		        {if (inL=="\x94"){return 148}
		         else
		         {if (inL=="\x95"){return 149}
		          else
		          {if (inL=="\x96"){return 150}
		           else
		           {if (inL=="\x97"){return 151}
		            else
		            {if (inL=="\x98"){return 152}
		             else
		             {if (inL=="\x99"){return 153}
		              else
		              {if (inL=="\x9A"){return 154}
		               else
		               {if (inL=="\x9B"){return 155}
		                else
		                {if (inL=="\x9C"){return 156}
		                 else
		                 {if (inL=="\x9D"){return 157}
		                  else
		                  {if (inL=="\x9E"){return 158}
		                   else
		                   {if (inL=="\x9F"){return 159}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\xA0"){return 160}
    else
     {if (inL=="\xA1"){return 161}
      else 
      {if (inL=="\xA2"){return 162}
       else
       {if (inL=="\xA3"){return 163}  
        else
        {if (inL=="\xA4"){return 164}
         else
         {if (inL=="\xA5"){return 165}
          else
          {if (inL=="\xA6"){return 166}
           else 
           {if (inL=="\xA7"){return 167}
            else
            {if (inL=="\xA8"){return 168}
             else
             {if (inL=="\xA9"){return 169}
              else
              {if (inL=="\xAA"){return 170}
               else
               {if (inL=="\xAB"){return 171}
                else
                {if (inL=="\xAC"){return 172}
                 else
                 {if (inL=="\xAD"){return 173}
                  else
                  {if (inL=="\xAE"){return 174}
		   else
		   {if (inL=="\xAF"){return 175}
 		    else
                    {if (inL=="\xB0"){return 176}
                     else
		     {if (inL=="\xB1"){return 177}
		      else
                      {if (inL=="\xB2"){return 178}
		       else
		       {if (inL=="\xB3"){return 179}
		        else
		        {if (inL=="\xB4"){return 180}
		         else
		         {if (inL=="\xB5"){return 181}
		          else
		          {if (inL=="\xB6"){return 182}
		           else
		           {if (inL=="\xB7"){return 183}
		            else
		            {if (inL=="\xB8"){return 184}
		             else
		             {if (inL=="\xB9"){return 185}
		              else
		              {if (inL=="\xBA"){return 186}
		               else
		               {if (inL=="\xBB"){return 187}
		                else
		                {if (inL=="\xBC"){return 188}
		                 else
		                 {if (inL=="\xBD"){return 189}
		                  else
		                  {if (inL=="\xBE"){return 190}
		                   else
		                   {if (inL=="\xBF"){return 191}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\xC0"){return 192}
    else
     {if (inL=="\xC1"){return 193}
      else 
      {if (inL=="\xC2"){return 194}
       else
       {if (inL=="\xC3"){return 195}  
        else
        {if (inL=="\xC4"){return 196}
         else
         {if (inL=="\xC5"){return 197}
          else
          {if (inL=="\xC6"){return 198}
           else 
           {if (inL=="\xC7"){return 199}
            else
            {if (inL=="\xC8"){return 200}
             else
             {if (inL=="\xC9"){return 201}
              else
              {if (inL=="\xCA"){return 202}
               else
               {if (inL=="\xCB"){return 203}
                else
                {if (inL=="\xCC"){return 204}
                 else
                 {if (inL=="\xCD"){return 205}
                  else
                  {if (inL=="\xCE"){return 206}
		   else
		   {if (inL=="\xCF"){return 207}
 		    else
                    {if (inL=="\xD0"){return 208}
                     else
		     {if (inL=="\xD1"){return 209}
		      else
                      {if (inL=="\xD2"){return 210}
		       else
		       {if (inL=="\xD3"){return 211}
		        else
		        {if (inL=="\xD4"){return 212}
		         else
		         {if (inL=="\xD5"){return 213}
		          else
		          {if (inL=="\xD6"){return 214}
		           else
		           {if (inL=="\xD7"){return 215}
		            else
		            {if (inL=="\xD8"){return 216}
		             else
		             {if (inL=="\xD9"){return 217}
		              else
		              {if (inL=="\xDA"){return 218}
		               else
		               {if (inL=="\xDB"){return 219}
		                else
		                {if (inL=="\xDC"){return 220}
		                 else
		                 {if (inL=="\xDD"){return 221}
		                  else
		                  {if (inL=="\xDE"){return 222}
		                   else
		                   {if (inL=="\xDF"){return 223}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\xE0"){return 224}
    else
     {if (inL=="\xE1"){return 225}
      else 
      {if (inL=="\xE2"){return 226}
       else
       {if (inL=="\xE3"){return 227}  
        else
        {if (inL=="\xE4"){return 228}
         else
         {if (inL=="\xE5"){return 229}
          else
          {if (inL=="\xE6"){return 230}
           else 
           {if (inL=="\xE7"){return 231}
            else
            {if (inL=="\xE8"){return 232}
             else
             {if (inL=="\xE9"){return 233}
              else
              {if (inL=="\xEA"){return 234}
               else
               {if (inL=="\xEB"){return 235}
                else
                {if (inL=="\xEC"){return 236}
                 else
                 {if (inL=="\xED"){return 237}
                  else
                  {if (inL=="\xEE"){return 238}
		   else
		   {if (inL=="\xEF"){return 239}
 		    else
                    {if (inL=="\xF0"){return 240}
                     else
		     {if (inL=="\xF1"){return 241}
		      else
                      {if (inL=="\xF2"){return 242}
		       else
		       {if (inL=="\xF3"){return 243}
		        else
		        {if (inL=="\xF4"){return 244}
		         else
		         {if (inL=="\xF5"){return 245}
		          else
		          {if (inL=="\xF6"){return 246}
		           else
		           {if (inL=="\xF7"){return 247}
		            else
		            {if (inL=="\xF8"){return 248}
		             else
		             {if (inL=="\xF9"){return 249}
		              else
		              {if (inL=="\xFA"){return 250}
		               else
		               {if (inL=="\xFB"){return 251}
		                else
		                {if (inL=="\xFC"){return 252}
		                 else
		                 {if (inL=="\xFD"){return 253}
		                  else
		                  {if (inL=="\xFE"){return 254}
		                   else
		                   {if (inL=="\xFF"){return 255}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

   }

  function CHR(inL){
    if (inL==48){return "0"} else
   {if (inL==49){return "1"} else
   {if (inL==50){return "2"} else
   {if (inL==51){return "3"} else
   {if (inL==52){return "4"} else
   {if (inL==53){return "5"} else
   {if (inL==54){return "6"} else
   {if (inL==55){return "7"} else
   {if (inL==56){return "8"} else
   {if (inL==57){return "9"} else
   {if (inL==58){return ":"} else
   {if (inL==59){return ";"} else
   {if (inL==60){return "<"} else
   {if (inL==61){return "="} else
   {if (inL==62){return ">"} else
   {if (inL==63){return "?"} else
   {if (inL==64){return "@"} else
   {if (inL==65){return "A"} else
   {if (inL==66){return "B"} else
   {if (inL==67){return "C"} else
   {if (inL==68){return "D"} else
   {if (inL==69){return "E"} else
   {if (inL==70){return "F"} else
   {if (inL==71){return "G"} else
   {if (inL==72){return "H"} else
   {if (inL==73){return "I"} else
   {if (inL==74){return "J"} else
   {if (inL==75){return "K"} else
   {if (inL==76){return "L"} else
   {if (inL==77){return "M"} else
   {if (inL==78){return "N"} else
     {if (inL==79){return "O"}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
                            
    if (inL==80){return "P"}  else    
    {if (inL==81){return "Q"} else                  
    {if (inL==82){return "R"} else
    {if (inL==83){return "S"} else
    {if (inL==84){return "T"} else
    {if (inL==85){return "U"} else
    {if (inL==86){return "V"} else
    {if (inL==87){return "W"} else
    {if (inL==88){return "X"} else
    {if (inL==89){return "Y"} else
    {if (inL==90){return "Z"} else
    {if (inL==91){return "["} else
    {if (inL==92){return "\\"} else
    {if (inL==93){return "]"} else
    {if (inL==94){return "^"} else
    {if (inL==95){return "_"} else
    {if (inL==96){return "`"} else
    {if (inL==97){return "a"} else
    {if (inL==98){return "b"} else
    {if (inL==99){return "c"} else
    {if (inL==100){return "d"}else
    {if (inL==101){return "e"}else
    {if (inL==102){return "f"}else
    {if (inL==103){return "g"}else
    {if (inL==104){return "h"}else
    {if (inL==105){return "i"}else
    {if (inL==106){return "j"}else
    {if (inL==107){return "k"}else
    {if (inL==108){return "l"}else
    {if (inL==109){return "m"}else
    {if (inL==110){return "n"}else
    {if (inL==111){return "o"}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL==112){return "p"}
    if (inL==113){return "q"}
    if (inL==114){return "r"}
    if (inL==115){return "s"}
    if (inL==116){return "t"}
    if (inL==117){return "u"}
    if (inL==118){return "v"}
    if (inL==119){return "w"}
    if (inL==120){return "x"}
    if (inL==121){return "y"}
    if (inL==122){return "z"}
    if (inL==123){return "{"}
    if (inL==124){return "|"}
    if (inL==125){return "}"}
    if (inL==126){return "~"}
    if (inL==127){return "\x7F"}
    if (inL==128){return "\x80"}
    if (inL==129){return "\x81"}
    if (inL==130){return "\x82"}
    if (inL==131){return "\x83"}
    if (inL==132){return "\x84"}
    if (inL==133){return "\x85"}
    if (inL==134){return "\x86"}
    if (inL==135){return "\x87"}
    if (inL==136){return "\x88"}
    if (inL==137){return "\x89"}
    if (inL==138){return "\x8A"}
    if (inL==139){return "\x8B"}
    if (inL==140){return "\x8C"}
    if (inL==141){return "\x8D"}
    if (inL==142){return "\x8E"}
    if (inL==143){return "\x8F"}

    if (inL==144){return "\x90"}
    if (inL==145){return "\x91"}
    if (inL==146){return "\x92"}
    if (inL==147){return "\x93"}
    if (inL==148){return "\x94"}
    if (inL==149){return "\x95"}
    if (inL==150){return "\x96"}
    if (inL==151){return "\x97"}
    if (inL==152){return "\x98"}
    if (inL==153){return "\x99"}
    if (inL==154){return "\x9A"}
    if (inL==155){return "\x9B"}
    if (inL==156){return "\x9C"}
    if (inL==157){return "\x9D"}
    if (inL==158){return "\x9E"}
    if (inL==159){return "\x9F"}
    if (inL==160){return "\xA0"}
    if (inL==161){return "\xA1"}
    if (inL==162){return "\xA2"}
    if (inL==163){return "\xA3"}
    if (inL==164){return "\xA4"}
    if (inL==165){return "\xA5"}
    if (inL==166){return "\xA6"}
    if (inL==167){return "\xA7"}
    if (inL==168){return "\xA8"}
    if (inL==169){return "\xA9"}
    if (inL==170){return "\xAA"}
    if (inL==171){return "\xAB"}
    if (inL==172){return "\xAC"}
    if (inL==173){return "\xAD"}
    if (inL==174){return "\xAE"}
    if (inL==175){return "\xAF"}


    if (inL==176){return "\xB0"}
    if (inL==177){return "\xB1"}
    if (inL==178){return "\xB2"}
    if (inL==179){return "\xB3"}
    if (inL==180){return "\xB4"}
    if (inL==181){return "\xB5"}
    if (inL==182){return "\xB6"}
    if (inL==183){return "\xB7"}
    if (inL==184){return "\xB8"}
    if (inL==185){return "\xB9"}
    if (inL==186){return "\xBA"}
    if (inL==187){return "\xBB"}
    if (inL==188){return "\xBC"}
    if (inL==189){return "\xBD"}
    if (inL==190){return "\xBE"}
    if (inL==191){return "\xBF"}
    if (inL==192){return "\xC0"}
    if (inL==193){return "\xC1"}
    if (inL==194){return "\xC2"}
    if (inL==195){return "\xC3"}
    if (inL==196){return "\xC4"}
    if (inL==197){return "\xC5"}
    if (inL==198){return "\xC6"}
    if (inL==199){return "\xC7"}
    if (inL==200){return "\xC8"}
    if (inL==201){return "\xC9"}
    if (inL==202){return "\xCA"}
    if (inL==203){return "\xCB"}
    if (inL==204){return "\xCC"}
    if (inL==205){return "\xCD"}
    if (inL==206){return "\xCE"}
    if (inL==207){return "\xCF"}

    if (inL==208){return "\xD0"}
    if (inL==209){return "\xD1"}
    if (inL==210){return "\xD2"}
    if (inL==211){return "\xD3"}
    if (inL==212){return "\xD4"}
    if (inL==213){return "\xD5"}
    if (inL==214){return "\xD6"}
    if (inL==215){return "\xD7"}
    if (inL==216){return "\xD8"}
    if (inL==217){return "\xD9"}
    if (inL==218){return "\xDA"}
    if (inL==219){return "\xDB"}
    if (inL==220){return "\xDC"}
    if (inL==221){return "\xDD"}
    if (inL==222){return "\xDE"}
    if (inL==223){return "\xDF"}
    if (inL==224){return "\xE0"}
    if (inL==225){return "\xE1"}
    if (inL==226){return "\xE2"}
    if (inL==227){return "\xE3"}
    if (inL==228){return "\xE4"}
    if (inL==229){return "\xE5"}
    if (inL==230){return "\xE6"}
    if (inL==231){return "\xE7"}
    if (inL==232){return "\xE8"}
    if (inL==233){return "\xE9"}
    if (inL==234){return "\xEA"}
    if (inL==235){return "\xEB"}
    if (inL==236){return "\xEC"}
    if (inL==237){return "\xED"}
    if (inL==238){return "\xEE"}
    if (inL==239){return "\xEF"}

    if (inL==240){return "\xF0"}
    if (inL==241){return "\xF1"}
    if (inL==242){return "\xF2"}
    if (inL==243){return "\xF3"}
    if (inL==244){return "\xF4"}
    if (inL==245){return "\xF5"}
    if (inL==246){return "\xF6"}
    if (inL==247){return "\xF7"}
    if (inL==248){return "\xF8"}
    if (inL==249){return "\xF9"}
    if (inL==250){return "\xFA"}
    if (inL==251){return "\xFB"}
    if (inL==252){return "\xFC"}
    if (inL==253){return "\xFD"}
    if (inL==254){return "\xFE"}
    if (inL==255){return "\xFF"}


    if (inL==0){return "\x0"}  else
    {if (inL==1){return "\x1"}  else
    {if (inL==2){return "\x2"}  else
    {if (inL==3){return "\x3"}  else
    {if (inL==4){return "\x4"}  else
    {if (inL==5){return "\x5"}  else
    {if (inL==6){return "\x6"}  else
    {if (inL==7){return "\x7"}  else
    {if (inL==8){return "\x8"}  else
    {if (inL==9){return "\x9"}  else
    {if (inL==10){return "\xA"} else
    {if (inL==11){return "\xB"} else
    {if (inL==12){return "\xC"} else
    {if (inL==13){return "\xD"} else
    {if (inL==14){return "\xE"} else
    {if (inL==15){return "\xF"} else
    {if (inL==16){return "\x10"} else
    {if (inL==17){return "\x11"} else
    {if (inL==18){return "\x12"} else
    {if (inL==19){return "\x13"} else
    {if (inL==20){return "\x14"} else
    {if (inL==21){return "\x15"} else
    {if (inL==22){return "\x16"} else
    {if (inL==23){return "\x17"} else
    {if (inL==24){return "\x18"} else
    {if (inL==25){return "\x19"} else
    {if (inL==26){return "\x1A"} else
    {if (inL==27){return "\x1B"} else
    {if (inL==28){return "\x1C"} else
    {if (inL==29){return "\x1D"} else
    {if (inL==30){return "\x1E"} else
    {if (inL==31){return "\x1F"}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}


    if (inL==32){return "\x20"}  else
    {if (inL==33){return "\x21"} else
    {if (inL==34){return "\x22"} else
    {if (inL==35){return "\x23"} else
    {if (inL==36){return "\x24"} else
    {if (inL==37){return "\x25"} else
    {if (inL==38){return "\x26"} else
    {if (inL==39){return "\x27"} else
    {if (inL==40){return "\x28"} else
    {if (inL==41){return "\x29"} else
    {if (inL==42){return "\x2A"} else
    {if (inL==43){return "\x2B"} else
    {if (inL==44){return "\x2C"} else
    {if (inL==45){return "\x2D"} else
    {if (inL==46){return "\x2E"} else
    {if (inL==47){return "\x2F"} 
}}}}}}}}}}}}}}}
  }




BEGIN{
print "\\def\\addmv{\\hskip0pt\\unskip}" > "tmp@.ind"
}
{
  {str=""
   kl=0
   inlinenew=$0
   len=length(inlinenew)
   sec=0
   kk=1
   for (k=1; k<=len;k++)
   {if (sec == 0)
        {
         ch=substr(inlinenew,kk,1)
         kk=k+1
         if (ch > "\240" && ch < "\372")
            {sec=1
             chpost=substr(inlinenew,kk,1)

#            if (chpost == "\143"){chpost="\136"}
#            if (chpost == "\144"){chpost="\137"}            
#            if (chpost == "\145"){chpost="\140"}                        
 

             if (chpost == "\236")
                {chpost="\200"}
             else 
                { if (chpost == "\140")
                    {chpost="\236"}
                  else
                    {if (chpost == "\141")
                        {chpost="\237"}
                     else
                        {if (chpost == "\142")
                           {chpost="\240"}
                         else
                           {
                            if (ASC(chpost) > 98 && ASC(chpost) < 102)
                              {chpost=CHR(ASC(chpost)-5)}
                            else
                              {
                                if (ASC(chpost) > 64 && ASC(chpost) < 91)
                                 {chpost=CHR(ASC(chpost)-1)}
                                else
                                 {
                                   if (ASC(chpost)== 95)
                                      {chpost=CHR(ASC(chpost)-5)}
                                 }  
                              }                             
                           }  
                        }    
                    }       
                }    
             kk=kk+1
             str=str ch chpost
            }
         else
            {str=str ch}   
        }
    else
       {sec=0}
   }

     ll1=index(str,"\\item")
     if (ll1 > 0) 
     {str=substr(str,1,ll1+4) "\\addmv" substr(str,ll1+5,length(str)-ll1-4)}
     outline=str
     print outline > "tmp@.ind"
  }
}   
END{}' $filea.ind
mv tmp@.ind $filea.ind
fi


if test "$Utf" = "y"; then
  iconv -f big5 -t UTF-8 -o tmp@.tex $filea.ind
  cp -f tmp@.tex $filea.ind
  mv -f $filea.idx@ $filea.idx
# else
fi


/bin/rm -f tmp@.* tmp@ tmp@.tex temp@idx tmp@mac bib*@ file*@ fname*2  sort*@ *.tmp@ 

#mv $filea.idx.bak $filea.idx

exit
exit



$gawkbin ' 
  function Transf(h){
   if (ASC(h) > 96 && ASC(h) <= 102)
       {decval=ASC(h)-87}
   else
       {decval=h}
   return decval 
  }

  function Trcode(inL){
    if (inL==""){return "^^80"}
    else
     {if (inL==""){return "^^81"}
      else 
      {if (inL==""){return "^^82"}
       else
      {if (inL==""){return "^^83"}
        else
      {if (inL==""){return "^^84"}
         else
       {if (inL==""){return "^^85"}
          else
            {if (inL==""){return "^^86"}
           else
            {if (inL==""){return "^^87"}
            else
            {if (inL==""){return "^^88"}
             else
            {if (inL==""){return "^^89"}
              else
            {if (inL==""){return "^^8a"}
               else
            {if (inL==""){return "^^8b"}
                else
            {if (inL==""){return "^^8c"}
                 else
            {if (inL==""){return "^^8d"}
                  else
                  {if (inL==""){return "^^8e"}
		   else
                    {if (inL==""){return "^^8f"}
 		    else
                    {if (inL==""){return "^^90"}
                     else
                    {if (inL==""){return "^^91"}
		      else
                    {if (inL==""){return "^^92"}
		       else
                    {if (inL==""){return "^^93"}
		        else
                    {if (inL==""){return "^^94"}
		         else
                    {if (inL==""){return "^^95"}
		          else
                    {if (inL==""){return "^^96"}
		           else
                             {if (inL==""){return "^^97"}
		            else
                            {if (inL==""){return "^^98"}
		             else
                            {if (inL==""){return "^^99"}
                             else
                            {if (inL==""){return "^^9a"}
		               else
                            {if (inL==""){return "^^9b"}
		                else
                            {if (inL==""){return "^^9c"}
		                 else
                            {if (inL==""){return "^^9d"}
		                  else
                            {if (inL==""){return "^^9e"}
		                else
                            {if (inL==""){return "^^9f"}
}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}

    if (inL==""){return "^^a0"} 
    else
   {if (inL==""){return "^^a1"}
      else
   {if (inL==""){return "^^a2"}
       else
   {if (inL==""){return "^^a3"}
        else
   {if (inL==""){return "^^a4"}
        else
   {if (inL==""){return "^^a5"}
        else
   {if (inL==""){return "^^a6"}
        else
   {if (inL==""){return "^^a7"}
        else
   {if (inL==""){return "^^a8"}
        else
   {if (inL==""){return "^^a9"}
        else
   {if (inL==""){return "^^aa"}
        else
   {if (inL==""){return "^^ab"}
        else
   {if (inL==""){return "^^ac"}
        else
   {if (inL==""){return "^^ad"}
        else
   {if (inL==""){return "^^ae"}
        else
   {if (inL==""){return "^^af"}
        else
                     {if (inL==""){return "^^b0"}
                     else
                     {if (inL==""){return "^^b1"}
		      else
                     {if (inL==""){return "^^b2"}
		       else
                     {if (inL==""){return "^^b3"}
		        else
                     {if (inL==""){return "^^b4"}
		         else
                     {if (inL==""){return "^^b5"}
		          else
                     {if (inL==""){return "^^b6"}
		           else
                     {if (inL==""){return "^^b7"}
		          else
                     {if (inL==""){return "^^b8"}
		          else
                     {if (inL==""){return "^^b9"}
		          else
                     {if (inL==""){return "^^ba"}
		          else
                     {if (inL==""){return "^^bb"}
		          else
                     {if (inL==""){return "^^bc"}
		          else
                     {if (inL==""){return "^^bd"}
		          else
                     {if (inL==""){return "^^be"}
		          else
                     {if (inL==""){return "^^bf"}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

      if (inL==""){return "^^c0"}
    else
     {if (inL==""){return "^^c1"}
      else
     {if (inL==""){return "^^c2"}
       else
     {if (inL==""){return "^^c3"}
        else
     {if (inL==""){return "^^c4"}
         else
     {if (inL==""){return "^^c5"}
          else
     {if (inL==""){return "^^c6"}
           else
     {if (inL==""){return "^^c7"}
          else
     {if (inL==""){return "^^c8"}
          else
     {if (inL==""){return "^^c9"}
          else
     {if (inL==""){return "^^ca"}
          else
     {if (inL==""){return "^^cb"}
          else
     {if (inL==""){return "^^cc"}
         else
     {if (inL==""){return "^^cd"}
         else
     {if (inL==""){return "^^ce"}
         else
     {if (inL==""){return "^^cf"}
 		    else
                    {if (inL==""){return "^^d0"}
                     else
                    {if (inL==""){return "^^d1"}
		      else
                    {if (inL==""){return "^^d2"}
		       else
                    {if (inL==""){return "^^d3"}
		        else
                    {if (inL==""){return "^^d4"}
		         else
                    {if (inL==""){return "^^d5"}
		          else
                    {if (inL==""){return "^^d6"}
		          else
                    {if (inL==""){return "^^d7"}
		         else
                    {if (inL==""){return "^^d8"}
		        else
                    {if (inL==""){return "^^d9"}
		         else
                    {if (inL==""){return "^^da"}
		         else
                    {if (inL==""){return "^^db"}
		         else
                    {if (inL==""){return "^^dc"}
		         else
                    {if (inL==""){return "^^dd"}
		         else
                    {if (inL==""){return "^^de"}
		         else
                    {if (inL==""){return "^^df"}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL==""){return "^^e0"}
    else
   {if (inL==""){return "^^e1"}
      else
   {if (inL==""){return "^^e2"}
       else
   {if (inL==""){return "^^e3"}
       else
   {if (inL==""){return "^^e4"}
       else
   {if (inL==""){return "^^e5"}
       else
   {if (inL==""){return "^^e6"}
       else
   {if (inL==""){return "^^e7"}
       else
   {if (inL==""){return "^^e8"}
       else
   {if (inL==""){return "^^e9"}
       else
   {if (inL==""){return "^^ea"}
       else
   {if (inL==""){return "^^eb"}
       else
   {if (inL==""){return "^^ec"}
       else
   {if (inL==""){return "^^ed"}
       else
   {if (inL==""){return "^^ee"}
      else
   {if (inL==""){return "^^ef"}
      else
                     {if (inL==""){return "^^f0"}
                     else
                     {if (inL==""){return "^^f1"}
		      else
                     {if (inL==""){return "^^f2"}
		       else
                     {if (inL==""){return "^^f3"}
		        else
                     {if (inL==""){return "^^f4"}
		         else
                     {if (inL==""){return "^^f5"}
                          else
                     {if (inL==""){return "^^f6"}
		           else
                     {if (inL==""){return "^^f7"}
		          else
                     {if (inL==""){return "^^f8"}
		          else
                     {if (inL==""){return "^^f9"}
		          else
                     {if (inL==""){return "^^fa"}
		          else
                     {if (inL==""){return "^^fb"}
		          else
                     {if (inL==""){return "^^fc"}
		          else
                     {if (inL==""){return "^^fd"}
		         else
                     {if (inL==""){return "^^fe"}
		         else
                     {if (inL==""){return "^^ff"}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

  }
  
  function InvTrcode(inL){
     if   (inL=="^^80"){return ""}
     else
      {if (inL=="^^81"){return ""}
      else
      {if (inL=="^^82"){return ""}
      else
      {if (inL=="^^83"){return ""}
      else
      {if (inL=="^^84"){return ""}
      else
         {if    (inL=="^^85"){return ""}
          else
            {if (inL=="^^86"){return ""}
           else
            {if (inL=="^^87"){return ""}
            else
            {if (inL=="^^88"){return ""}
            else
            {if (inL=="^^89"){return ""}
            else
            {if (inL=="^^8a"){return ""}
            else
            {if (inL=="^^8b"){return ""}
            else
            {if (inL=="^^8c"){return ""}
            else
            {if (inL=="^^8d"){return ""}
             else
                    {if (inL=="^^8e"){return ""}
                   else
                    {if (inL=="^^8f"){return ""}
                    else
                    {if (inL=="^^90"){return ""}
                    else
                    {if (inL=="^^91"){return ""}
                    else
                    {if (inL=="^^92"){return ""}
                    else
                    {if (inL=="^^93"){return ""}
                    else
                    {if (inL=="^^94"){return ""}
                    else
                    {if (inL=="^^95"){return ""}
                    else
                    {if (inL=="^^96"){return ""}
                    else
                            {if (inL=="^^97"){return ""}
                            else
                            {if (inL=="^^98"){return ""}
                            else
                            {if (inL=="^^99"){return ""}
                            else
                            {if (inL=="^^9a"){return ""}
                            else
                            {if (inL=="^^9b"){return ""}
                            else
                            {if (inL=="^^9c"){return ""}
                            else
                            {if (inL=="^^9d"){return ""}
                            else
                            {if (inL=="^^9e"){return ""}
                            else
                            {if (inL=="^^9f"){return ""}
}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}

    if (inL=="^^a0"){return ""}
   else
   {if (inL=="^^a1"){return ""}
   else
   {if (inL=="^^a2"){return ""}
   else
   {if (inL=="^^a3"){return ""}
   else
   {if (inL=="^^a4"){return ""}
   else
   {if (inL=="^^a5"){return ""}
   else
   {if (inL=="^^a6"){return ""}
   else
   {if (inL=="^^a7"){return ""}
   else
   {if (inL=="^^a8"){return ""}
   else
   {if (inL=="^^a9"){return ""}
   else
   {if (inL=="^^aa"){return ""}
   else
   {if (inL=="^^ab"){return ""}
   else
   {if (inL=="^^ac"){return ""}
   else
   {if (inL=="^^ad"){return ""}
   else
   {if (inL=="^^ae"){return ""}
   else
   {if (inL=="^^af"){return ""}
   else
                     {if (inL=="^^b0"){return ""}
                     else
                     {if (inL=="^^b1"){return ""}
                     else
                     {if (inL=="^^b2"){return ""}
                     else
                     {if (inL=="^^b3"){return ""}
                     else
                     {if (inL=="^^b4"){return ""}
                     else
                     {if (inL=="^^b5"){return ""}
                     else
                     {if (inL=="^^b6"){return ""}
                     else
                     {if (inL=="^^b7"){return ""}
                     else
                     {if (inL=="^^b8"){return ""}
                     else
                     {if (inL=="^^b9"){return ""}
                     else
                     {if (inL=="^^ba"){return ""}
                     else
                     {if (inL=="^^bb"){return ""}
                     else
                     {if (inL=="^^bc"){return ""}
                     else
                     {if (inL=="^^bd"){return ""}
                     else
                     {if (inL=="^^be"){return ""}
                     else
                     {if (inL=="^^bf"){return ""}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

      if (inL=="^^c0"){return ""}
     else
     {if (inL=="^^c1"){return ""}
     else
     {if (inL=="^^c2"){return ""}
     else
     {if (inL=="^^c3"){return ""}
     else
     {if (inL=="^^c4"){return ""}
     else
     {if (inL=="^^c5"){return ""}
     else
     {if (inL=="^^c6"){return ""}
     else
     {if (inL=="^^c7"){return ""}
     else
     {if (inL=="^^c8"){return ""}
     else
     {if (inL=="^^c9"){return ""}
     else
     {if (inL=="^^ca"){return ""}
     else
     {if (inL=="^^cb"){return ""}
     else
     {if (inL=="^^cc"){return ""}
     else
     {if (inL=="^^cd"){return ""}
     else
     {if (inL=="^^ce"){return ""}
     else
     {if (inL=="^^cf"){return ""}
     else
                    {if (inL=="^^d0"){return ""}
                    else
                    {if (inL=="^^d1"){return ""}
                    else
                    {if (inL=="^^d2"){return ""}
                    else
                    {if (inL=="^^d3"){return ""}
                    else
                    {if (inL=="^^d4"){return ""}
                    else
                    {if (inL=="^^d5"){return ""}
                    else
                    {if (inL=="^^d6"){return ""}
                    else
                    {if (inL=="^^d7"){return ""}
                    else
                    {if (inL=="^^d8"){return ""}
                    else
                    {if (inL=="^^d9"){return ""}
                    else
                    {if (inL=="^^da"){return ""}
                    else
                    {if (inL=="^^db"){return ""}
                    else
                    {if (inL=="^^dc"){return ""}
                    else
                    {if (inL=="^^dd"){return ""}
                    else
                    {if (inL=="^^de"){return ""}
                    else
                    {if (inL=="^^df"){return ""}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="^^e0"){return ""}
   else
   {if (inL=="^^e1"){return ""}
   else
   {if (inL=="^^e2"){return ""}
   else
   {if (inL=="^^e3"){return ""}
   else
   {if (inL=="^^e4"){return ""}
   else
   {if (inL=="^^e5"){return ""}
   else
   {if (inL=="^^e6"){return ""}
   else
   {if (inL=="^^e7"){return ""}
   else
   {if (inL=="^^e8"){return ""}
   else
   {if (inL=="^^e9"){return ""}
   else
   {if (inL=="^^ea"){return ""}
   else
   {if (inL=="^^eb"){return ""}
   else
   {if (inL=="^^ec"){return ""}
   else
   {if (inL=="^^ed"){return ""}
   else
   {if (inL=="^^ee"){return ""}
   else
   {if (inL=="^^ef"){return ""}
   else
                     {if (inL=="^^f0"){return ""}
                     else
                     {if (inL=="^^f1"){return ""}
                     else
                     {if (inL=="^^f2"){return ""}
                     else
                     {if (inL=="^^f3"){return ""}
                     else
                     {if (inL=="^^f4"){return ""}
                     else
                     {if (inL=="^^f5"){return ""}
                     else
                     {if (inL=="^^f6"){return ""}
                     else
                     {if (inL=="^^f7"){return ""}
                     else
                     {if (inL=="^^f8"){return ""}
                     else
                     {if (inL=="^^f9"){return ""}
                     else
                     {if (inL=="^^fa"){return ""}
                     else
                     {if (inL=="^^fb"){return ""}
                     else
                     {if (inL=="^^fc"){return ""}
                     else
                     {if (inL=="^^fd"){return ""}
                     else
                     {if (inL=="^^fe"){return ""}
                     else
                     {if (inL=="^^ff"){return ""}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

  }
  
  
  
  

  function ASC(inL){
    if (inL=="\x00"){return 0}  else 
    {if (inL=="\x01"){return 1}  else
    {if (inL=="\x02"){return 2}  else
    {if (inL=="\x03"){return 3}  else
    {if (inL=="\x04"){return 4}  else
    {if (inL=="\x05"){return 5}  else
    {if (inL=="\x06"){return 6}  else
    {if (inL=="\x07"){return 7}  else
    {if (inL=="\x08"){return 8}  else
    {if (inL=="\x09"){return 9}  else
    {if (inL=="\x0A"){return 10} else
    {if (inL=="\x0B"){return 11} else
    {if (inL=="\x0C"){return 12} else
    {if (inL=="\x0D"){return 13} else
    {if (inL=="\x0E"){return 14} else
    {if (inL=="\x0F"){return 15} else
    {if (inL=="\x10"){return 16} else
    {if (inL=="\x11"){return 17} else
    {if (inL=="\x12"){return 18} else
    {if (inL=="\x13"){return 19} else
    {if (inL=="\x14"){return 20} else
    {if (inL=="\x15"){return 21} else
    {if (inL=="\x16"){return 22} else
    {if (inL=="\x17"){return 23} else
    {if (inL=="\x18"){return 24} else
   {if (inL=="\x19"){return 25}  else
   {if (inL=="\x1A"){return 26}  else
   {if (inL=="\x1B"){return 27}  else
   {if (inL=="\x1C"){return 28}  else
   {if (inL=="\x1D"){return 29}  else
   {if (inL=="\x1E"){return 30}  else
   {if (inL=="\x1F"){return 31}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\x20"){return 32}
    else
     {if (inL=="\x21"){return 33}
      else 
      {if (inL=="\x22"){return 34}
       else
       {if (inL=="\x23"){return 35}  
        else
        {if (inL=="\x24"){return 36}
         else
         {if (inL=="\x25"){return 37}
          else
          {if (inL=="\x26"){return 38}
           else 
           {if (inL=="\x27"){return 39}
            else
            {if (inL=="\x28"){return 40}
             else
             {if (inL=="\x29"){return 41}
              else
              {if (inL=="\x2A"){return 42}
               else
               {if (inL=="\x2B"){return 43}
                else
                {if (inL=="\x2C"){return 44}
                 else
                 {if (inL=="\x2D"){return 45}
                  else
                  {if (inL=="\x2E"){return 46}
		   else
		   {if (inL=="\x2F"){return 47}
 		    else
                    {if (inL=="\x30"){return 48}
                     else
		     {if (inL=="\x31"){return 49}
		      else
                      {if (inL=="\x32"){return 50}
		       else
		       {if (inL=="\x33"){return 51}
		        else
		        {if (inL=="\x34"){return 52}
		         else
		         {if (inL=="\x35"){return 53}
		          else
		          {if (inL=="\x36"){return 54}
		           else
		           {if (inL=="\x37"){return 55}
		            else
		            {if (inL=="\x38"){return 56}
		             else
		             {if (inL=="\x39"){return 57}
		              else
		              {if (inL=="\x3A"){return 58}
		               else
		               {if (inL=="\x3B"){return 59}
		                else
		                {if (inL=="\x3C"){return 60}
		                 else
		                 {if (inL=="\x3D"){return 61}
		                  else
		                  {if (inL=="\x3E"){return 62}
		                   else
		                   {if (inL=="\x3F"){return 63}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\x40"){return 64}
    else
     {if (inL=="\x41"){return 65}
      else 
      {if (inL=="\x42"){return 66}
       else
       {if (inL=="\x43"){return 67}  
        else
        {if (inL=="\x44"){return 68}
         else
         {if (inL=="\x45"){return 69}
          else
          {if (inL=="\x46"){return 70}
           else 
           {if (inL=="\x47"){return 71}
            else
            {if (inL=="\x48"){return 72}
             else
             {if (inL=="\x49"){return 73}
              else
              {if (inL=="\x4A"){return 74}
               else
               {if (inL=="\x4B"){return 75}
                else
                {if (inL=="\x4C"){return 76}
                 else
                 {if (inL=="\x4D"){return 77}
                  else
                  {if (inL=="\x4E"){return 78}
		   else
		   {if (inL=="\x4F"){return 79}
 		    else
                    {if (inL=="\x50"){return 80}
                     else
		     {if (inL=="\x51"){return 81}
		      else
                      {if (inL=="\x52"){return 82}
		       else
		       {if (inL=="\x53"){return 83}
		        else
		        {if (inL=="\x54"){return 84}
		         else
		         {if (inL=="\x55"){return 85}
		          else
		          {if (inL=="\x56"){return 86}
		           else
		           {if (inL=="\x57"){return 87}
		            else
		            {if (inL=="\x58"){return 88}
		             else
		             {if (inL=="\x59"){return 89}
		              else
		              {if (inL=="\x5A"){return 90}
		               else
		               {if (inL=="\x5B"){return 91}
		                else
		                {if (inL=="\x5C"){return 92}
		                 else
		                 {if (inL=="\x5D"){return 93}
		                  else
		                  {if (inL=="\x5E"){return 94}
		                   else
		                   {if (inL=="\x5F"){return 95}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\x60"){return 96}
    else
     {if (inL=="\x61"){return 97}
      else 
      {if (inL=="\x62"){return 98}
       else
       {if (inL=="\x63"){return 99}  
        else
        {if (inL=="\x64"){return 100}
         else
         {if (inL=="\x65"){return 101}
          else
          {if (inL=="\x66"){return 102}
           else 
           {if (inL=="\x67"){return 103}
            else
            {if (inL=="\x68"){return 104}
             else
             {if (inL=="\x69"){return 105}
              else
              {if (inL=="\x6A"){return 106}
               else
               {if (inL=="\x6B"){return 107}
                else
                {if (inL=="\x6C"){return 108}
                 else
                 {if (inL=="\x6D"){return 109}
                  else
                  {if (inL=="\x6E"){return 110}
		   else
		   {if (inL=="\x6F"){return 111}
 		    else
                    {if (inL=="\x70"){return 112}
                     else
		     {if (inL=="\x71"){return 113}
		      else
                      {if (inL=="\x72"){return 114}
		       else
		       {if (inL=="\x73"){return 115}
		        else
		        {if (inL=="\x74"){return 116}
		         else
		         {if (inL=="\x75"){return 117}
		          else
		          {if (inL=="\x76"){return 118}
		           else
		           {if (inL=="\x77"){return 119}
		            else
		            {if (inL=="\x78"){return 120}
		             else
		             {if (inL=="\x79"){return 121}
		              else
		              {if (inL=="\x7A"){return 122}
		               else
		               {if (inL=="\x7B"){return 123}
		                else
		                {if (inL=="\x7C"){return 124}
		                 else
		                 {if (inL=="\x7D"){return 125}
		                  else
		                  {if (inL=="\x7E"){return 126}
		                   else
		                   {if (inL=="\x7F"){return 127}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\x80"){return 128}
    else
     {if (inL=="\x81"){return 129}
      else 
      {if (inL=="\x82"){return 130}
       else
       {if (inL=="\x83"){return 131}  
        else
        {if (inL=="\x84"){return 132}
         else
         {if (inL=="\x85"){return 133}
          else
          {if (inL=="\x86"){return 134}
           else 
           {if (inL=="\x87"){return 135}
            else
            {if (inL=="\x88"){return 136}
             else
             {if (inL=="\x89"){return 137}
              else
              {if (inL=="\x8A"){return 138}
               else
               {if (inL=="\x8B"){return 139}
                else
                {if (inL=="\x8C"){return 140}
                 else
                 {if (inL=="\x8D"){return 141}
                  else
                  {if (inL=="\x8E"){return 142}
		   else
		   {if (inL=="\x8F"){return 143}
 		    else
                    {if (inL=="\x90"){return 144}
                     else
		     {if (inL=="\x91"){return 145}
		      else
                      {if (inL=="\x92"){return 146}
		       else
		       {if (inL=="\x93"){return 147}
		        else
		        {if (inL=="\x94"){return 148}
		         else
		         {if (inL=="\x95"){return 149}
		          else
		          {if (inL=="\x96"){return 150}
		           else
		           {if (inL=="\x97"){return 151}
		            else
		            {if (inL=="\x98"){return 152}
		             else
		             {if (inL=="\x99"){return 153}
		              else
		              {if (inL=="\x9A"){return 154}
		               else
		               {if (inL=="\x9B"){return 155}
		                else
		                {if (inL=="\x9C"){return 156}
		                 else
		                 {if (inL=="\x9D"){return 157}
		                  else
		                  {if (inL=="\x9E"){return 158}
		                   else
		                   {if (inL=="\x9F"){return 159}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\xA0"){return 160}
    else
     {if (inL=="\xA1"){return 161}
      else 
      {if (inL=="\xA2"){return 162}
       else
       {if (inL=="\xA3"){return 163}  
        else
        {if (inL=="\xA4"){return 164}
         else
         {if (inL=="\xA5"){return 165}
          else
          {if (inL=="\xA6"){return 166}
           else 
           {if (inL=="\xA7"){return 167}
            else
            {if (inL=="\xA8"){return 168}
             else
             {if (inL=="\xA9"){return 169}
              else
              {if (inL=="\xAA"){return 170}
               else
               {if (inL=="\xAB"){return 171}
                else
                {if (inL=="\xAC"){return 172}
                 else
                 {if (inL=="\xAD"){return 173}
                  else
                  {if (inL=="\xAE"){return 174}
		   else
		   {if (inL=="\xAF"){return 175}
 		    else
                    {if (inL=="\xB0"){return 176}
                     else
		     {if (inL=="\xB1"){return 177}
		      else
                      {if (inL=="\xB2"){return 178}
		       else
		       {if (inL=="\xB3"){return 179}
		        else
		        {if (inL=="\xB4"){return 180}
		         else
		         {if (inL=="\xB5"){return 181}
		          else
		          {if (inL=="\xB6"){return 182}
		           else
		           {if (inL=="\xB7"){return 183}
		            else
		            {if (inL=="\xB8"){return 184}
		             else
		             {if (inL=="\xB9"){return 185}
		              else
		              {if (inL=="\xBA"){return 186}
		               else
		               {if (inL=="\xBB"){return 187}
		                else
		                {if (inL=="\xBC"){return 188}
		                 else
		                 {if (inL=="\xBD"){return 189}
		                  else
		                  {if (inL=="\xBE"){return 190}
		                   else
		                   {if (inL=="\xBF"){return 191}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\xC0"){return 192}
    else
     {if (inL=="\xC1"){return 193}
      else 
      {if (inL=="\xC2"){return 194}
       else
       {if (inL=="\xC3"){return 195}  
        else
        {if (inL=="\xC4"){return 196}
         else
         {if (inL=="\xC5"){return 197}
          else
          {if (inL=="\xC6"){return 198}
           else 
           {if (inL=="\xC7"){return 199}
            else
            {if (inL=="\xC8"){return 200}
             else
             {if (inL=="\xC9"){return 201}
              else
              {if (inL=="\xCA"){return 202}
               else
               {if (inL=="\xCB"){return 203}
                else
                {if (inL=="\xCC"){return 204}
                 else
                 {if (inL=="\xCD"){return 205}
                  else
                  {if (inL=="\xCE"){return 206}
		   else
		   {if (inL=="\xCF"){return 207}
 		    else
                    {if (inL=="\xD0"){return 208}
                     else
		     {if (inL=="\xD1"){return 209}
		      else
                      {if (inL=="\xD2"){return 210}
		       else
		       {if (inL=="\xD3"){return 211}
		        else
		        {if (inL=="\xD4"){return 212}
		         else
		         {if (inL=="\xD5"){return 213}
		          else
		          {if (inL=="\xD6"){return 214}
		           else
		           {if (inL=="\xD7"){return 215}
		            else
		            {if (inL=="\xD8"){return 216}
		             else
		             {if (inL=="\xD9"){return 217}
		              else
		              {if (inL=="\xDA"){return 218}
		               else
		               {if (inL=="\xDB"){return 219}
		                else
		                {if (inL=="\xDC"){return 220}
		                 else
		                 {if (inL=="\xDD"){return 221}
		                  else
		                  {if (inL=="\xDE"){return 222}
		                   else
		                   {if (inL=="\xDF"){return 223}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL=="\xE0"){return 224}
    else
     {if (inL=="\xE1"){return 225}
      else 
      {if (inL=="\xE2"){return 226}
       else
       {if (inL=="\xE3"){return 227}  
        else
        {if (inL=="\xE4"){return 228}
         else
         {if (inL=="\xE5"){return 229}
          else
          {if (inL=="\xE6"){return 230}
           else 
           {if (inL=="\xE7"){return 231}
            else
            {if (inL=="\xE8"){return 232}
             else
             {if (inL=="\xE9"){return 233}
              else
              {if (inL=="\xEA"){return 234}
               else
               {if (inL=="\xEB"){return 235}
                else
                {if (inL=="\xEC"){return 236}
                 else
                 {if (inL=="\xED"){return 237}
                  else
                  {if (inL=="\xEE"){return 238}
		   else
		   {if (inL=="\xEF"){return 239}
 		    else
                    {if (inL=="\xF0"){return 240}
                     else
		     {if (inL=="\xF1"){return 241}
		      else
                      {if (inL=="\xF2"){return 242}
		       else
		       {if (inL=="\xF3"){return 243}
		        else
		        {if (inL=="\xF4"){return 244}
		         else
		         {if (inL=="\xF5"){return 245}
		          else
		          {if (inL=="\xF6"){return 246}
		           else
		           {if (inL=="\xF7"){return 247}
		            else
		            {if (inL=="\xF8"){return 248}
		             else
		             {if (inL=="\xF9"){return 249}
		              else
		              {if (inL=="\xFA"){return 250}
		               else
		               {if (inL=="\xFB"){return 251}
		                else
		                {if (inL=="\xFC"){return 252}
		                 else
		                 {if (inL=="\xFD"){return 253}
		                  else
		                  {if (inL=="\xFE"){return 254}
		                   else
		                   {if (inL=="\xFF"){return 255}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

   }

  function CHR(inL){
    if (inL==48){return "0"} else
   {if (inL==49){return "1"} else
   {if (inL==50){return "2"} else
   {if (inL==51){return "3"} else
   {if (inL==52){return "4"} else
   {if (inL==53){return "5"} else
   {if (inL==54){return "6"} else
   {if (inL==55){return "7"} else
   {if (inL==56){return "8"} else
   {if (inL==57){return "9"} else
   {if (inL==58){return ":"} else
   {if (inL==59){return ";"} else
   {if (inL==60){return "<"} else
   {if (inL==61){return "="} else
   {if (inL==62){return ">"} else
   {if (inL==63){return "?"} else
   {if (inL==64){return "@"} else
   {if (inL==65){return "A"} else
   {if (inL==66){return "B"} else
   {if (inL==67){return "C"} else
   {if (inL==68){return "D"} else
   {if (inL==69){return "E"} else
   {if (inL==70){return "F"} else
   {if (inL==71){return "G"} else
   {if (inL==72){return "H"} else
   {if (inL==73){return "I"} else
   {if (inL==74){return "J"} else
   {if (inL==75){return "K"} else
   {if (inL==76){return "L"} else
   {if (inL==77){return "M"} else
   {if (inL==78){return "N"} else
     {if (inL==79){return "O"}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
                            
    if (inL==80){return "P"}  else    
    {if (inL==81){return "Q"} else                  
    {if (inL==82){return "R"} else
    {if (inL==83){return "S"} else
    {if (inL==84){return "T"} else
    {if (inL==85){return "U"} else
    {if (inL==86){return "V"} else
    {if (inL==87){return "W"} else
    {if (inL==88){return "X"} else
    {if (inL==89){return "Y"} else
    {if (inL==90){return "Z"} else
    {if (inL==91){return "["} else
    {if (inL==92){return "\\"} else
    {if (inL==93){return "]"} else
    {if (inL==94){return "^"} else
    {if (inL==95){return "_"} else
    {if (inL==96){return "`"} else
    {if (inL==97){return "a"} else
    {if (inL==98){return "b"} else
    {if (inL==99){return "c"} else
    {if (inL==100){return "d"}else
    {if (inL==101){return "e"}else
    {if (inL==102){return "f"}else
    {if (inL==103){return "g"}else
    {if (inL==104){return "h"}else
    {if (inL==105){return "i"}else
    {if (inL==106){return "j"}else
    {if (inL==107){return "k"}else
    {if (inL==108){return "l"}else
    {if (inL==109){return "m"}else
    {if (inL==110){return "n"}else
    {if (inL==111){return "o"}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    if (inL==112){return "p"}
    if (inL==113){return "q"}
    if (inL==114){return "r"}
    if (inL==115){return "s"}
    if (inL==116){return "t"}
    if (inL==117){return "u"}
    if (inL==118){return "v"}
    if (inL==119){return "w"}
    if (inL==120){return "x"}
    if (inL==121){return "y"}
    if (inL==122){return "z"}
    if (inL==123){return "{"}
    if (inL==124){return "|"}
    if (inL==125){return "}"}
    if (inL==126){return "~"}
    if (inL==127){return "\x7F"}
    if (inL==128){return "\x80"}
    if (inL==129){return "\x81"}
    if (inL==130){return "\x82"}
    if (inL==131){return "\x83"}
    if (inL==132){return "\x84"}
    if (inL==133){return "\x85"}
    if (inL==134){return "\x86"}
    if (inL==135){return "\x87"}
    if (inL==136){return "\x88"}
    if (inL==137){return "\x89"}
    if (inL==138){return "\x8A"}
    if (inL==139){return "\x8B"}
    if (inL==140){return "\x8C"}
    if (inL==141){return "\x8D"}
    if (inL==142){return "\x8E"}
    if (inL==143){return "\x8F"}

    if (inL==144){return "\x90"}
    if (inL==145){return "\x91"}
    if (inL==146){return "\x92"}
    if (inL==147){return "\x93"}
    if (inL==148){return "\x94"}
    if (inL==149){return "\x95"}
    if (inL==150){return "\x96"}
    if (inL==151){return "\x97"}
    if (inL==152){return "\x98"}
    if (inL==153){return "\x99"}
    if (inL==154){return "\x9A"}
    if (inL==155){return "\x9B"}
    if (inL==156){return "\x9C"}
    if (inL==157){return "\x9D"}
    if (inL==158){return "\x9E"}
    if (inL==159){return "\x9F"}
    if (inL==160){return "\xA0"}
    if (inL==161){return "\xA1"}
    if (inL==162){return "\xA2"}
    if (inL==163){return "\xA3"}
    if (inL==164){return "\xA4"}
    if (inL==165){return "\xA5"}
    if (inL==166){return "\xA6"}
    if (inL==167){return "\xA7"}
    if (inL==168){return "\xA8"}
    if (inL==169){return "\xA9"}
    if (inL==170){return "\xAA"}
    if (inL==171){return "\xAB"}
    if (inL==172){return "\xAC"}
    if (inL==173){return "\xAD"}
    if (inL==174){return "\xAE"}
    if (inL==175){return "\xAF"}


    if (inL==176){return "\xB0"}
    if (inL==177){return "\xB1"}
    if (inL==178){return "\xB2"}
    if (inL==179){return "\xB3"}
    if (inL==180){return "\xB4"}
    if (inL==181){return "\xB5"}
    if (inL==182){return "\xB6"}
    if (inL==183){return "\xB7"}
    if (inL==184){return "\xB8"}
    if (inL==185){return "\xB9"}
    if (inL==186){return "\xBA"}
    if (inL==187){return "\xBB"}
    if (inL==188){return "\xBC"}
    if (inL==189){return "\xBD"}
    if (inL==190){return "\xBE"}
    if (inL==191){return "\xBF"}
    if (inL==192){return "\xC0"}
    if (inL==193){return "\xC1"}
    if (inL==194){return "\xC2"}
    if (inL==195){return "\xC3"}
    if (inL==196){return "\xC4"}
    if (inL==197){return "\xC5"}
    if (inL==198){return "\xC6"}
    if (inL==199){return "\xC7"}
    if (inL==200){return "\xC8"}
    if (inL==201){return "\xC9"}
    if (inL==202){return "\xCA"}
    if (inL==203){return "\xCB"}
    if (inL==204){return "\xCC"}
    if (inL==205){return "\xCD"}
    if (inL==206){return "\xCE"}
    if (inL==207){return "\xCF"}

    if (inL==208){return "\xD0"}
    if (inL==209){return "\xD1"}
    if (inL==210){return "\xD2"}
    if (inL==211){return "\xD3"}
    if (inL==212){return "\xD4"}
    if (inL==213){return "\xD5"}
    if (inL==214){return "\xD6"}
    if (inL==215){return "\xD7"}
    if (inL==216){return "\xD8"}
    if (inL==217){return "\xD9"}
    if (inL==218){return "\xDA"}
    if (inL==219){return "\xDB"}
    if (inL==220){return "\xDC"}
    if (inL==221){return "\xDD"}
    if (inL==222){return "\xDE"}
    if (inL==223){return "\xDF"}
    if (inL==224){return "\xE0"}
    if (inL==225){return "\xE1"}
    if (inL==226){return "\xE2"}
    if (inL==227){return "\xE3"}
    if (inL==228){return "\xE4"}
    if (inL==229){return "\xE5"}
    if (inL==230){return "\xE6"}
    if (inL==231){return "\xE7"}
    if (inL==232){return "\xE8"}
    if (inL==233){return "\xE9"}
    if (inL==234){return "\xEA"}
    if (inL==235){return "\xEB"}
    if (inL==236){return "\xEC"}
    if (inL==237){return "\xED"}
    if (inL==238){return "\xEE"}
    if (inL==239){return "\xEF"}

    if (inL==240){return "\xF0"}
    if (inL==241){return "\xF1"}
    if (inL==242){return "\xF2"}
    if (inL==243){return "\xF3"}
    if (inL==244){return "\xF4"}
    if (inL==245){return "\xF5"}
    if (inL==246){return "\xF6"}
    if (inL==247){return "\xF7"}
    if (inL==248){return "\xF8"}
    if (inL==249){return "\xF9"}
    if (inL==250){return "\xFA"}
    if (inL==251){return "\xFB"}
    if (inL==252){return "\xFC"}
    if (inL==253){return "\xFD"}
    if (inL==254){return "\xFE"}
    if (inL==255){return "\xFF"}


    if (inL==0){return "\x0"}  else
    {if (inL==1){return "\x1"}  else
    {if (inL==2){return "\x2"}  else
    {if (inL==3){return "\x3"}  else
    {if (inL==4){return "\x4"}  else
    {if (inL==5){return "\x5"}  else
    {if (inL==6){return "\x6"}  else
    {if (inL==7){return "\x7"}  else
    {if (inL==8){return "\x8"}  else
    {if (inL==9){return "\x9"}  else
    {if (inL==10){return "\xA"} else
    {if (inL==11){return "\xB"} else
    {if (inL==12){return "\xC"} else
    {if (inL==13){return "\xD"} else
    {if (inL==14){return "\xE"} else
    {if (inL==15){return "\xF"} else
    {if (inL==16){return "\x10"} else
    {if (inL==17){return "\x11"} else
    {if (inL==18){return "\x12"} else
    {if (inL==19){return "\x13"} else
    {if (inL==20){return "\x14"} else
    {if (inL==21){return "\x15"} else
    {if (inL==22){return "\x16"} else
    {if (inL==23){return "\x17"} else
    {if (inL==24){return "\x18"} else
    {if (inL==25){return "\x19"} else
    {if (inL==26){return "\x1A"} else
    {if (inL==27){return "\x1B"} else
    {if (inL==28){return "\x1C"} else
    {if (inL==29){return "\x1D"} else
    {if (inL==30){return "\x1E"} else
    {if (inL==31){return "\x1F"}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}


    if (inL==32){return "\x20"}  else
    {if (inL==33){return "\x21"} else
    {if (inL==34){return "\x22"} else
    {if (inL==35){return "\x23"} else
    {if (inL==36){return "\x24"} else
    {if (inL==37){return "\x25"} else
    {if (inL==38){return "\x26"} else
    {if (inL==39){return "\x27"} else
    {if (inL==40){return "\x28"} else
    {if (inL==41){return "\x29"} else
    {if (inL==42){return "\x2A"} else
    {if (inL==43){return "\x2B"} else
    {if (inL==44){return "\x2C"} else
    {if (inL==45){return "\x2D"} else
    {if (inL==46){return "\x2E"} else
    {if (inL==47){return "\x2F"} 
}}}}}}}}}}}}}}}
  }

  function Toctrl(inL){
     ll=length(inL)
     j=1; cc=""
     for (j;j<=ll;j++)
      {ch=substr(inL,j,1)
       if (ASC(ch)>127)
          {ch1=substr(inL,j-1,1)
           ch2=substr(inL,j+1,1)
#           if (ch1=="}" && ch2=="}")
              {ch=Trcode(ch)}
          }      
       cc=cc ch   
      }
     return cc
  }

  function Toctrll(inL){
    dbr=1; wline=""
    rinL=inL
    while (dbr>0)
     {
      lbr=index(rinL,"{")
      rbr=index(rinL,"}")
      if (lbr==0 || rbr==0){lbr=1}
      if (lbr<rbr)
         {dbr=1
          inbr=substr(rinL,lbr+1,rbr-lbr-1)
          llinL=substr(rinL,1,lbr); rrinL=substr(rinL,rbr+1,length(rinL)-rbr)
          ll=length(inbr)
          j=1; cc=""
          for (j;j<=ll;j++)
            {ch=substr(inbr,j,1)
             ch=Trcode(ch)
             cc=cc ch
            }
          wline=wline llinL cc "}"
          rinL=rrinL
         }
      else
         {dbr=0
          wline=wline rinL
         }   
     }
     return wline
     
  } 
  
BEGIN{
}
{ 
   inline=$0
   strhead=1
   outline=""
   kk=0


  while (strhead > 0)
  {
    strhead=index(inline,"\\bc@BG \\ch@WP \\ch@PP{")
    strheada=index(inline,"\\bc@cBG \\ch@WP \\ch@PP{")

    if (strheada == 0){strheada=10000}
    if (strhead == 0){strhead=10000}
    if (strhead==10000 && strheada==10000)
       {strhead=0; strheada=0}

    if (strhead > 0 && strhead < strheada)
       {strheada=0}

    if (strheada > 0 && strheada < strhead)
       {strhead=0}

    if (strhead > 0)
       {headadd=21}
    else
       {if (strheada > 0)
         {strhead=strheada
          headadd=22
         }
       }   

    if (strhead > 0)
      {
        inline=Toctrl(inline)       

        firstbyte=substr(inline,strhead+headadd,2)
        fchar=substr(firstbyte,1,1)
        fchar=tolower(fchar)
        lchar=substr(firstbyte,2,1)
        kk=kk+1

         if (lchar == "a")
          {lchar="1"}
         else
          {if (lchar == "b")           
            {lchar="2"}
           else
            {if (lchar == "c")
              {lchar="3"}
             else
              {if (lchar == "d")           
                {lchar="4"}
               else
                {if (lchar == "e")
                  {lchar="5"}
                 else
                  {if (lchar == "f")           
                    {lchar="6"}
                   else
                    {if (lchar == "g")
                      {lchar="7"}
                     else
                      {if (lchar == "h")           
                        {lchar="8"}
                       else
                        {if (lchar == "i")
                          {lchar="9"}
                         else
                          {if (lchar == "j")
                            {lchar="0"}
                           else
                            {lchar=tolower(lchar)}
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }

         firstbyte=fchar lchar
         leftstr=substr(inline,1,strhead-1)
         rightstr=substr(inline,strhead+headadd+3,length(inline)-strhead-headadd-2)

         nextpr=index(rightstr,"}")

         secondbyte=substr(rightstr,2,nextpr-2)
         graphstr=substr(secondbyte,1,2)
         graph=0

#         if (graphstr == "^^"){graph=1}


         if (length(secondbyte) == 1 && secondbyte > "\200") then
            {graph=2}
            
            
         if (graphstr == "^^"){graph=1}
         if (graph > 0)
           { if (graph == 2)
               { secondbyte=substr(secondbyte,1,1)
                 txtch=""

                 if (ASC(secondbyte)<128)
                    {txtch="y"}
                 else    
                    {secondbyte=Trcode(secondbyte)}
               }
             else
               {if (graph == 1)
                 {secondbyte=InvTrcode(secondbyte);txtch="y"}
               }  
                
                if (txtch=="") 
                   {ffchar=tolower(substr(secondbyte,3,2))}
                else
                   {ffchar=secondbyte}


#            if (ffchar == "\135"){rffchar="\142"}
#            if (ffchar == "\136"){rffchar="\143"}
#            if (ffchar == "\137"){rffchar="\144"}            
#            if (ffchar == "\140"){rffchar="\145"}                        
            
            if (ASC(ffchar) == 128)
#               {rffchar="^^" CHR(158)}
               {rffchar=CHR(158)}
            else
              {if (ASC(ffchar) > 157 && ASC(ffchar) < 161)
#                  {rffchar="^^" CHR(ASC(ffchar)-62)}
                  {rffchar=CHR(ASC(ffchar)-62)}
               else
                  {
                   if (ASC(ffchar) > 93 && ASC(ffchar) < 97)
#                      {}
                      {rffchar=CHR(ASC(ffchar)+5)}
                   else
                      { 
                      if (ASC(ffchar) > 63 && ASC(ffchar) < 90)
                         {rffchar=CHR(ASC(ffchar)+1)}
                       else  
                        {
                         if (ASC(ffchar)== 90)
                           {rffchar=CHR(ASC(ffchar)+5)}
                         else
                          {         
                            if (txtch=="")
                               {rffchar="^^" ffchar}
                            else
                               {rffchar=ffchar}   
                          }    
                        }   
                      }   
                  }    
              }
             secondbyte=rffchar
           }

        h=substr(firstbyte,1,1); hh=Transf(h)
        h=substr(firstbyte,length(firstbyte),1); tt=Transf(h)
        firstbyteval=hh*16+tt


        outline=outline leftstr CHR(firstbyteval) secondbyte

        strheadn=index(rightstr,"\\bc@BG \\ch@WP \\ch@PP{")
        strheadna=index(rightstr,"\\bc@cBG \\ch@WP \\ch@PP{")
    if (strheadna == 0){strheadna=10000}
    if (strheadn == 0){strheadn=10000}
    if (strheadn==10000 && strheadna==10000)
       {strheadn=0; strheadna=0}

    if (strheadn > 0 && strheadn < strheadna)
       {strheadna=0}

    if (strheadna > 0 && strheadna < strheadn)
       {strheadn=0}

    if (strheadn > 0)
       {headaddn=21}
    else
       {if (strheadna > 0)
         {strheadn=strheadna
          headaddn=22
         }
       }   


       inline=substr(rightstr,nextpr+1,length(rightstr)-nextpr)

#       if (strheadn >0)
#          {inline=substr(rightstr,strheadn)}
#       else
#          {inline=substr(rightstr,nextpr+1,length(rightstr)-nextpr)}

      }
    else
      {if (kk == 0)
          {outline=inline}
       else
         {if (graph == 2)   
             { 
               if (substr(outline,length(outline),1)=="}")
                  {outline=substr(outline,1,length(outline)-1)}
               if (substr(outline,length(outline),1) != "}" && substr(inline,1,1) != "}" )
                  {
#                   if (substr(inline,1,1) ="{" && substr(inline,length(inline),1) ="}")
#                      {subinline=substr(inline,2,length(inline)-2)
                      
                       llen=length(inline)
                       NunNumber=""
                       i=1
                       for (i; i<=llen; i++)
                        {ch=substr(inline,i,1)
                         if ((ASC(ch)<48 || ASC(ch)>57) && ASC(ch)!=123 && ASC(ch)!=125)
                            {NunNumber="y"; break}
                        }   
                             
                        if (NunNumber=="")                                       
                           {outline=outline "}" inline}
                        else
                           {outline=outline inline}
                  }
              else  
               {outline=outline inline}
             }
          else
             {outline=outline inline}
         }    
      } 
  }             

    print outline > "tmp@.iii" 

}                 
END{
} ' gawkbin=$gawkbin $filea.idx  > /dev/null 2>&1 
