秀丸エディタ用マクロです。

* Update: 2015/05/23

ファイル名:native2ascii.mac

// ネイティブ --> ASCII(\uXXXX) コンバート ver2

setcompatiblemode 0x00020200;	//検索での表示=範囲選択
#lineno = lineno;
#count = 0;

escape;
begingroupundo;
disabledraw;
gofiletop;
searchdown2 "[\\u{000080}-\\u{10FFFF}]", regular, nohilight;	// ○HMJRE.DLL ○hmonig.dll ×JRE32.DLL ×BRegIf.dll
while (result) {
	#u = unicode;
	if (#u >= 0x010000) {	// サロゲートペア
		#u = #u - 0x010000;
		insert "\\u" + rightstr("000" + hex(#u / 0x0400 + 0xD800), 4)
		     + "\\u" + rightstr("000" + hex(#u % 0x0400 + 0xDC00), 4);
	}
	else
		insert "\\u" + rightstr("000" + hex(#u), 4);
	#count = #count + 1;
	if (tickcount - #time >= 1000) {
		#time = tickcount;
		#i = 1000 * lineno / linecount;
		title "native2ascii - 変換文字数:" + str(#count) + " (" + str(#i / 10) + "." + str(#i % 10) + "%)";
	}
	finddown2;
}
movetolineno 0, #lineno;
enabledraw;
endgroupundo;
endmacro;
ファイル名:native2ascii-reverse.mac
// ASCII(\uXXXX) --> ネイティブ コンバート ver2

setcompatiblemode 0x00020200;	//検索での表示=範囲選択
#lineno = lineno;
#count = 0;

escape;
begingroupundo;
disabledraw;
gofiletop;
searchdown2 "\\\\u[0-9A-F]{4}", nocasesense, regular, nohilight;
while (result) {
	#u = val("0x" + gettext(seltopx + 2, seltopy, selendx, selendy, 1));
	if (#u >= 0xD800 && #u <= 0xDBFF && tolower(gettext(selendx + 1, seltopy, selendx + 3, selendy, 1)) == "\\ud") {
		#v = val("0x" + gettext(selendx + 3, seltopy, selendx + 6, selendy, 1));
		if (#v >= 0xDC00 && #v <= 0xDFFF)
			#u = (#u - 0xD800) * 0x0400 + #v - 0xDC00 + 0x10000;	// サロゲートペア
	}
	insert unichar(#u);
	#count = #count + 1;
	if (tickcount - #time >= 1000) {
		#time = tickcount;
		#i = 1000 * lineno / linecount;
		title "native2ascii reverse - 変換文字数:" + str(#count) + " (" + str(#i / 10) + "." + str(#i % 10) + "%)";
	}
	finddown2;
}
title 0;
movetolineno 0, #lineno;
enabledraw;
endgroupundo;
endmacro;