// rtfconv.mac // //「Rtfconv.dll」の著作権は、針谷壮一氏にあります。 //「Rtfconv.dll」の入手先は、http://www5b.biglobe.ne.jp/~harigaya/ です。 //DLLの場所(それぞれの環境に合わせて変更してください) $Dll_Name = "C:\\Rtfcnv\\rtfconv.dll"; $FILE = filename; if ($FILE == "") { message "(無題) は処理できません。\n" + "名前を付けて保存してから実行して下さい。\n"; goto END;} if (updated==1) { save;} $Name = basename2; //出力ファイル(それぞれの環境に合わせて変更してください) $OUTTXT = "C:\\Temp\\Rtfconv処理済み" + $Name; #ch = charset; if (#ch==1){ #in = 932; $in = "Shift-JIS";} else if (#ch==2){ #in = 1200; $in = "Unicode";} else if (#ch==3){ #in = 51932; $in = "EUC";} else if (#ch==4){ #in = 50220; $in = "JIS";} else if (#ch==6){ #in = 65001; $in = "UTF-8";} else if (#ch==7){ #in = 1201; $in = "Unicode(Big Endian)";} else if (#ch==9){ #in = 936; $in = "GB";} else if (#ch==10){ #in = 950; $in = "BIG5";} else { message "当マクロでは、このコードページからの変換はサポートしていません。"; goto END;} $m[0] = $in + " => Shift-JIS"; //1 Shift-JISへの変換 $m[1] = $in + " => GB"; //2 GBへの変換 $m[2] = $in + " => BIG5"; //3 BIG5への変換 $m[3] = $in + " => Unicode"; //4 Unicodeへの変換 $m[4] = $in + " => Unicode(Big Endian)"; //5 Unicode(Big Endian)への変換 $m[5] = $in + " => UTF-8"; //6 UTF-8への変換 $m[6] = $in + " => Shift-JIS(異体字検索OFF)"; //7 Shift-JISへの変換、異体字検索OFF menuarray $m,7; if (result== 0) goto END; else if (result== 1) { #out = 932; #en = 1; #no_variant = 0;} else if (result== 2) { #out = 936; #en = 9; #no_variant = 0;} else if (result== 3) { #out = 950; #en = 10; #no_variant = 0;} else if (result== 4) { #out = 1200; #en = 2; #no_variant = 0;} else if (result== 5) { #out = 1201; #en = 7; #no_variant = 0;} else if (result== 6) { #out = 65001; #en = 6; #no_variant = 0;} else if (result== 7) { #out = 932; #en = 1; #no_variant = 2;} //DLLのロード loaddll $Dll_Name; //オプションについては、「rtfconv.h」参照。 //「コード番号をHTML形式で出力」「HTML形式のコード番号を認識」「コード番号をサロゲートペアで出力」、#no_variantは異体字検索。 #option = 0x200000 + 0x400000 + 0x4000000 + #no_variant; $s = dllfuncstr("Rtfconv", $FILE, $OUTTXT, #in, #out, #option); freedll; openfile $OUTTXT; setencode #en, 0; //念のため //以下は16進数のUnicode番号「&#xhhhh;」を10進数「&#nnnnn;」に変換する処理。 disabledraw; $hex = "&#x[0-9|A-F][0-9|A-F][0-9|A-F][0-9|A-F];"; gofiletop; searchdown2 $hex, regular; while( result ) { call Hex2Dec; insert "&#" + $$return + ";"; finddown2; } gofiletop; save; END: endmacro; Hex2Dec: ##tx = seltopx; ##ty = seltopy; ##ex = selendx; ##ey = selendy; $$s = gettext(##tx, ##ty, ##ex, ##ey); escape; ##c1 = ascii(midstr($$s, 3, 1)); ##c2 = ascii(midstr($$s, 4, 1)); ##c3 = ascii(midstr($$s, 5, 1)); ##c4 = ascii(midstr($$s, 6, 1)); if ('A'<=##c1 && ##c1<='Z') ##c1 = ##c1 + 32; if ('0'<=##c1 && ##c1<='9') ##c1 = ##c1 - '0'; else if ('a'<=##c1 && ##c1<='f') ##c1 = ##c1 - 'a' + 10; if ('A'<=##c2 && ##c2<='Z') ##c2 = ##c2 + 32; if ('0'<=##c2 && ##c2<='9') ##c2 = ##c2 - '0'; else if ('a'<=##c2 && ##c2<='f') ##c2 = ##c2 - 'a' + 10; if ('A'<=##c3 && ##c3<='Z') ##c3 = ##c3 + 32; if ('0'<=##c3 && ##c3<='9') ##c3 = ##c3 - '0'; else if ('a'<=##c3 && ##c3<='f') ##c3 = ##c3 - 'a' + 10; if ('A'<=##c4 && ##c4<='Z') ##c4 = ##c4 + 32; if ('0'<=##c4 && ##c4<='9') ##c4 = ##c4 - '0'; else if ('a'<=##c4 && ##c4<='f') ##c4 = ##c4 - 'a' + 10; ##r = ##c1 * 0x1000 + ##c2 * 0x100 + ##c3 * 0x10 + ##c4; $$d = str(##r); beginsel; moveto ##ex, ##ey; return $$d;