1@x 2@d my_name=='ppltotf' 3@d banner=='This is pPLtoTF, Version 3.6-p1.8' 4@y 5@d my_name=='uppltotf' 6@d banner=='This is upPLtoTF, Version 3.6-p1.8-u1.20' 7@z 8 9@x 10 usage_help (PPLTOTF_HELP, nil); 11@y 12 usage_help (UPPLTOTF_HELP, nil); 13@z 14 15@x 16max_kanji=7237; { maximam number of 2byte characters } 17@y 18max_kanji=65535; { maximam number of 2byte characters } 19@z 20 21@x function get_next_raw 22if multistrlen(ustringcast(buffer),loc+2,loc)=2 then cur_char:=" " 23@y 24if multistrlen(ustringcast(buffer),loc+3,loc)>1 then cur_char:=" " 25@z 26 27@x function valid_jis_code 28var @!first_byte,@!second_byte:integer; { jis code bytes } 29begin valid_jis_code:=true; 30first_byte:=cx div @'400; second_byte:=cx mod @'400; 31if (first_byte<@"21) 32 or((first_byte>@"28)and(first_byte<@"30)) 33 or(first_byte>@"74) then valid_jis_code:=false; 34if (second_byte<@"21)or(second_byte>@"7E) then valid_jis_code:=false; 35@y 36begin valid_jis_code:=true; 37if (cx>@"FFFF)or(not is_char_kanji(fromDVI(cx))) 38 or(toDVI(fromDVI(cx))<>cx) then valid_jis_code:=false; 39@z 40 41@x function jis_to_index 42var @!first_byte,@!second_byte:integer; { jis code bytes } 43begin 44first_byte:=jis div @'400 -@"21; 45second_byte:=jis mod @'400 -@"21; 46if first_byte<8 then 47 jis_to_index:=first_byte*94+second_byte 48else { next |first_byte| start 16 } 49 jis_to_index:=(first_byte-7)*94+second_byte; 50@y 51begin 52jis_to_index:=jis; 53@z 54 55@x function index_to_jis 56begin if ix<=8*94-1 then 57 index_to_jis:=(ix div 94 +@"21)*@'400+(ix mod 94 +@"21) 58else 59 index_to_jis:=((ix+7*94) div 94 +@"21)*@'400+((ix+7*94) mod 94 +@"21); 60@y 61begin 62index_to_jis:=ix; 63@z 64 65@x function get_kanji 66else if multistrlen(ustringcast(buffer), loc+2, loc)=2 then 67 begin jis_code:=toDVI(fromBUFF(ustringcast(buffer), loc+2, loc)); 68 incr(loc); cur_char:=" "; 69@y 70else if (ch='U')or(ch='u') then 71 begin repeat ch:=get_next_raw; until ch<>' '; 72 cx:=todig(xord[ch])*@"1000; 73 incr(loc); ch:=xord[buffer[loc]]; cx:=cx+todig(ch)*@"100; 74 incr(loc); ch:=xord[buffer[loc]]; cx:=cx+todig(ch)*@"10; 75 incr(loc); ch:=xord[buffer[loc]]; cx:=cx+todig(ch); 76 jis_code:=toDVI(fromUCS(cx)); 77 cur_char:=ch; 78 if not valid_jis_code(jis_code) then 79 err_print('jis code ', jis_code:1, ' is invalid'); 80 end 81else if multistrlen(ustringcast(buffer), loc+4, loc)>1 then 82 begin cur_char:=" "; 83 jis_code:=toDVI(fromBUFF(ustringcast(buffer), loc+4, loc)); 84 loc:=loc+multistrlen(ustringcast(buffer), loc+4, loc)-1; 85@z 86 87