#4148

takuya
参加者

=====================================
名前:開いているファイルの半角カナを全角カナへ
版:1.0
用途:半角カナを全角カタカナに変換したいとき
コメント:変換関数は水沢・penguin-19・和彦様のホームページにあったモノを転用させていただきました。
作ったものの、よく考えたらEmEditorに同じ機能が。。。
供養させてください。。。macro作成の参考例になればイイかと思って。あげときます。
=====================================

Window.Redraw = false;
document.selection.SelectAll();
var text = document.selection.Text;
document.selection.Text = toZenkaku( text );
document.selection.Collapse();
Window.Redraw = true;
////////
///toZenkaku()関数オリジナルはココのサイトから
///http://www.kiwi-us.com/~mizusawa/penguin/html_hint/java_s_kana.html
///
function toZenkaku( str ){
//配列を用意する
hankaku = new Array(“ガ”, “ギ”, “グ”, “ゲ”, “ゴ”,
“ザ”, “ジ”, “ズ”, “ゼ”, “ゾ”, “ダ”, “ヂ”, “ヅ”,
“デ”, “ド”, “バ”, “パ”, “ビ”, “ピ”, “ブ”, “プ”,
“ベ”, “ペ”, “ボ”, “ポ”, “ヴ”, “ァ”, “ア”, “ィ”, “イ”,
“ゥ”, “ウ”, “ェ”, “エ”, “ォ”, “オ”, “カ”, “キ”, “ク”, “ケ”,
“コ”, “サ”, “シ”, “ス”, “セ”, “ソ”, “タ”, “チ”, “ッ”, “ツ”,
“テ”, “ト”, “ナ”, “ニ”, “ヌ”, “ネ”, “ノ”, “ハ”, “ヒ”, “フ”,
“ヘ”, “ホ”, “マ”, “ミ”, “ム”, “メ”, “モ”, “ャ”, “ヤ”, “ュ”,
“ユ”, “ョ”, “ヨ”, “ラ”, “リ”, “ル”, “レ”, “ロ”, “ワ”, “ヲ”,
“ン”, “。”, “「”, “」”, “、”, “・”, “ー”, “゙”, “゚”);
zenkaku = new Array(“ガ”, “ギ”, “グ”, “ゲ”, “ゴ”,
“ザ”, “ジ”, “ズ”, “ゼ”, “ゾ”, “ダ”, “ヂ”, “ヅ”, “デ”,
“ド”, “バ”, “パ”, “ビ”, “ピ”, “ブ”, “プ”, “ベ”, “ペ”,
“ボ”, “ポ”, “ヴ”, “ァ”, “ア”, “ィ”, “イ”, “ゥ”, “ウ”,
“ェ”, “エ”, “ォ”, “オ”, “カ”, “キ”, “ク”, “ケ”, “コ”,
“サ”, “シ”, “ス”, “セ”, “ソ”, “タ”, “チ”, “ッ”, “ツ”,
“テ”, “ト”, “ナ”, “ニ”, “ヌ”, “ネ”, “ノ”, “ハ”, “ヒ”,
“フ”, “ヘ”, “ホ”, “マ”, “ミ”, “ム”, “メ”, “モ”, “ャ”,
“ヤ”, “ュ”, “ユ”, “ョ”, “ヨ”, “ラ”, “リ”, “ル”, “レ”,
“ロ”, “ワ”, “ヲ”, “ン”, “。”, “「”, “」”, “、”, “・”,
“ー”, “゛”, “゜”);
thismoji = str; // 文字を取得
//変換開始
for (i=0; i= 0){ //該当する半角カナがなくなるまで繰り返す
thismoji = thismoji.replace(hankaku, zenkaku); //半角カナに対応する全角カナに置換する
}
}
return thismoji;
}