// jis to sjis converter by Murata // Usage: jis2sj [InputFile [OutputFile]] import java.io.*; class jis2sj { public static void main(String args[]) { InputStream fi = System.in; OutputStream fo = System.out; boolean kmode = false; int ESC = 0x1b, kin = '$', kout = '('; int ci, c[] = new int[2]; try{ if(args.length>0) fi = (InputStream)(new FileInputStream(args[0])); if(args.length>1) fo = (OutputStream)(new FileOutputStream(args[1])); while( (ci = fi.read()) != -1){ if(!kmode){ if(ci == ESC){ if(fi.read() == kin) kmode = true; fi.read(); }else{ fo.write(ci); } }else{ if(ci == ESC){ if(fi.read() == kout) kmode = false; fi.read(); }else{ c[0] = ci; c[1] = fi.read(); jis2sj1(c); fo.write(c[0]); fo.write(c[1]); } } } }catch(IOException e){ System.out.println(e.toString()); System.exit(1); }finally{ try{ fo.close(); fi.close(); }catch(IOException e){} } } static void jis2sj1(int c[]){ c[1] += (c[0] & 1) == 0 ? 0x7e : (c[1] < 0x60 ? 0x1f : 0x20); c[0] = (c[0] < 0x5f ? c[0] + 0xe1 : c[0] + 0x161) >> 1; } }