tell application "Finder" display dialog "英辞郎で検索する" default answer "" buttons {"キャンセル", "実行Firefox", "実行Safari"} with icon 1 with title "英辞郎 on the Webで辞書引きする" default button 3 if button returned of the result is "実行Firefox" then set Encoded_Text to text returned of the result as Unicode text set Decoded_Text to do shell script "echo '" & Encoded_Text & "' | iconv -f UTF-8-MAC -t UTF-8 | perl -pe '~s/(\\W)/\"%\".unpack(\"H2\", $1)/eg;'" set Decoded_Text to my replaceTxt(Decoded_Text, "%0a", "") set MyURL to "http://eow.alc.co.jp/" & Decoded_Text & "/UTF-8/" as Unicode text tell application "Firefox" activate OpenURL MyURL end tell else if button returned of the result is "実行Safari" then set Original_Text to text returned of the result as Unicode text set Encoded_Text to do shell script "echo '" & Original_Text & "' | iconv -f UTF-8-MAC -t UTF-8" set MyURL to "http://eow.alc.co.jp/" & Encoded_Text & "/UTF-8/" as Unicode text tell application "Safari" activate make new document with properties {name:"eow.alc.co.jp"} tell window 1 open location MyURL end tell end tell end if end tell on replaceTxt(myText, searchTxt, replaceTxt) set oldDel to AppleScript's text item delimiters set AppleScript's text item delimiters to searchTxt set myText to every text item of myText set AppleScript's text item delimiters to replaceTxt set myText to myText as string set AppleScript's text item delimiters to oldDel return myText end replaceTxt