#include <stdio.h>
int main(int argc,char* argv[]){
  int bk = -1;
  int bk1 = -1;
  int bk2 = -1;
  int bk3 = -1;
  int notescape = 0;
  int val = -1;
  if (argc <3){
printf("Usage: euckrfix inputfile outputfile\n");
    return -1;
  }
  FILE* in =fopen(argv[1],"rb");
  FILE* out = fopen(argv[2],"wb");
  if (in == NULL){
printf("Can not open inputfile:%s\n",argv[1]);
    return -1;
  }
  if (out == NULL){
printf("Can not open outputfile:%s\n",argv[2]);
    return -1;
  }
  while(feof(in) == 0){
    val = getc(in);
    if (bk == '"' && bk1 == 'B' && bk2 == '$' && bk3 == ''){
      putc('\\',out);
      putc(bk,out);
    }else{
      if (bk != -1){
        putc(bk,out);
      }
    }
    bk3 = bk2;
    bk2 = bk1;
    bk1 = bk;
    bk = val;
  }
  return 0;
}
