#11078

phew
メンバー

=====================================
名前: Vietnamese Combining Chars to Precomposed
版: 1.0
概要: Unicode のベトナム語の結合文字列(Combining Character Sequence)を合成済み文字(Precomposed Character)に置換します。

註記: !! UTF-16LE with Singature で保存してください !!

ネットで使用されているベトナム語のほとんどは合成済み文字ですが、まれに結合文字列を使用したものがあります。再利用の際に不便なのでもっとベタなマクロを自作して使っていましたが、takuya さんのマクロ「開いているファイルの半角カナを全角カナへ」を拝見し、早速利用させていただくことにしました。ありがとうございます! そのまんま使わせていただきました。

なお、ベトナム語には声調記号以外にも母音自体を区別する補助記号があるため、いくつかの文字は結合文字列で表す場合2通りの方法があります。つまり、”Au0306u0301″ と “u0102u0301” はどちらも、合成済み文字 “u1eae” と正規等価です。このマクロはどちらでも使えるはずです。

Window.Redraw = false;
document.selection.SelectAll();
var text = document.selection.Text;
document.selection.Text = C2P( text );
document.selection.Collapse();
Window.Redraw = true;

function C2P( str ){
combiningchar = new Array(“á”,”Á”,”à”,”À”,”ả”,”Ả”,”ã”,”Ô,”ạ”,”Ạ”,”ắ”,”Ắ”,”ằ”,”Ằ”,”ẳ”,”Ẳ”,”ẵ”,”Ẵ”,”ặ”,”Ặ”,”ắ”,”Ắ”,”ằ”,”Ằ”,”ẳ”,”Ẳ”,”ẵ”,”Ẵ”,”ặ”,”Ặ”,”ă”,”Ă”,”ấ”,”Ấ”,”ầ”,”Ầ”,”ẩ”,”Ẩ”,”ẫ”,”Ẫ”,”ậ”,”Ậ”,”ấ”,”Ấ”,”ầ”,”Ầ”,”ẩ”,”Ẩ”,”ẫ”,”Ẫ”,”ậ”,”Ậ”,”â”,””,”é”,”É”,”è”,”È”,”ẻ”,”Ẻ”,”ẽ”,”Ẽ”,”ẹ”,”Ẹ”,”ế”,”Ế”,”ề”,”Ề”,”ể”,”Ể”,”ễ”,”Ễ”,”ệ”,”Ệ”,”ế”,”Ế”,”ề”,”Ề”,”ể”,”Ể”,”ễ”,”Ễ”,”ệ”,”Ệ”,”ê”,”Ê”,”í”,”Í”,”ì”,”Ì”,”ỉ”,”Ỉ”,”ĩ”,”Ĩ”,”ị”,”Ị”,”ó”,”Ó”,”ò”,”Ò”,”ỏ”,”Ỏ”,”õ”,”Õ”,”ọ”,”Ọ”,”ớ”,”Ớ”,”ờ”,”Ờ”,”ở”,”Ở”,”ỡ”,”Ỡ”,”ợ”,”Ợ”,”ớ”,”Ớ”,”ờ”,”Ờ”,”ở”,”Ở”,”ỡ”,”Ỡ”,”ợ”,”Ợ”,”ơ”,”Ơ”,”ố”,”Ố”,”ồ”,”Ồ”,”ổ”,”Ổ”,”ỗ”,”Ỗ”,”ộ”,”Ộ”,”ố”,”Ố”,”ồ”,”Ồ”,”ổ”,”Ổ”,”ỗ”,”Ỗ”,”ộ”,”Ộ”,”ô”,”Ô”,”ú”,”Ú”,”ù”,”Ù”,”ủ”,”Ủ”,”ũ”,”Ũ”,”ụ”,”Ụ”,”ứ”,”Ứ”,”ừ”,”Ừ”,”ử”,”Ử”,”ữ”,”Ữ”,”ự”,”Ự”,”ứ”,”Ứ”,”ừ”,”Ừ”,”ử”,”Ử”,”ữ”,”Ữ”,”ự”,”Ự”,”ư”,”Ư”,”ý”,”Ý”,”ỳ”,”Ỳ”,”ỷ”,”Ỷ”,”ỹ”,”Ỹ”,”ỵ”,”Ỵ”);
precomposedchar = new Array(“á”,”Á”,”à”,”À”,”ả”,”Ả”,”ã”,”Ô,”ạ”,”Ạ”,”ắ”,”Ắ”,”ằ”,”Ằ”,”ẳ”,”Ẳ”,”ẵ”,”Ẵ”,”ặ”,”Ặ”,”ắ”,”Ắ”,”ằ”,”Ằ”,”ẳ”,”Ẳ”,”ẵ”,”Ẵ”,”ặ”,”Ặ”,”ă”,”Ă”,”ấ”,”Ấ”,”ầ”,”Ầ”,”ẩ”,”Ẩ”,”ẫ”,”Ẫ”,”ậ”,”Ậ”,”ấ”,”Ấ”,”ầ”,”Ầ”,”ẩ”,”Ẩ”,”ẫ”,”Ẫ”,”ậ”,”Ậ”,”â”,””,”é”,”É”,”è”,”È”,”ẻ”,”Ẻ”,”ẽ”,”Ẽ”,”ẹ”,”Ẹ”,”ế”,”Ế”,”ề”,”Ề”,”ể”,”Ể”,”ễ”,”Ễ”,”ệ”,”Ệ”,”ế”,”Ế”,”ề”,”Ề”,”ể”,”Ể”,”ễ”,”Ễ”,”ệ”,”Ệ”,”ê”,”Ê”,”í”,”Í”,”ì”,”Ì”,”ỉ”,”Ỉ”,”ĩ”,”Ĩ”,”ị”,”Ị”,”ó”,”Ó”,”ò”,”Ò”,”ỏ”,”Ỏ”,”õ”,”Õ”,”ọ”,”Ọ”,”ớ”,”Ớ”,”ờ”,”Ờ”,”ở”,”Ở”,”ỡ”,”Ỡ”,”ợ”,”Ợ”,”ớ”,”Ớ”,”ờ”,”Ờ”,”ở”,”Ở”,”ỡ”,”Ỡ”,”ợ”,”Ợ”,”ơ”,”Ơ”,”ố”,”Ố”,”ồ”,”Ồ”,”ổ”,”Ổ”,”ỗ”,”Ỗ”,”ộ”,”Ộ”,”ố”,”Ố”,”ồ”,”Ồ”,”ổ”,”Ổ”,”ỗ”,”Ỗ”,”ộ”,”Ộ”,”ô”,”Ô”,”ú”,”Ú”,”ù”,”Ù”,”ủ”,”Ủ”,”ũ”,”Ũ”,”ụ”,”Ụ”,”ứ”,”Ứ”,”ừ”,”Ừ”,”ử”,”Ử”,”ữ”,”Ữ”,”ự”,”Ự”,”ứ”,”Ứ”,”ừ”,”Ừ”,”ử”,”Ử”,”ữ”,”Ữ”,”ự”,”Ự”,”ư”,”Ư”,”ý”,”Ý”,”ỳ”,”Ỳ”,”ỷ”,”Ỷ”,”ỹ”,”Ỹ”,”ỵ”,”Ỵ”);
thischar = str;
for (i=0; i= 0){
thischar = thischar.replace(combiningchar, precomposedchar);
}
}
return thischar;
}