Unicode(utf16)を取り扱う概要秀丸エディタのデータや、外部データがutf16の範囲の文字列であっても、 UTF16のマクロファイルこれまで秀丸マクロをcp932(ShiftJIS)にて保存してきましたが、 #dll = loaddll( hidemarudir + @"\hmPy.dll" ); #r = dllfuncw( #dll, "SetCodePage", 1200 ); // utf-16 #r = dllfuncw( #dll, "SetStrVar", "currentmacrodirectory", currentmacrodirectory ); #r = dllfuncw( #dll, "DoString", R"IRONPYTHON( import clr result = "あああ♬♬♬♬♬あああ" )IRONPYTHON" ); $result = dllfuncstrw( #dll, "GetStrVar", "result" ); message($result); #_ = dllfuncw( #dll, "DestroyScope" ); freedll(#dll); cp932での記載との違いは以下の3つとなります。
.pyファイルを外部に出す場合には、utf-16のcoding指定「DoFile」を使うなど、.pyファイルを外部に出す際は、マクロをcp932で保存していた際には「#coding:cp932」を指定していましたが、 例えば、以下のような「myunicode.py」を用意し、Unicode(utf16)で保存します。 #coding: utf-16 import clr result = "あああ♬♬♬♬♬あああ" マクロ側で以下のように呼び出す形となります。 #dll = loaddll( hidemarudir + @"\hmPy.dll" ); #r = dllfuncw( #dll, "SetCodePage", 1200 ); #r = dllfuncw( #dll, "SetStrVar", "currentmacrodirectory", currentmacrodirectory ); #r = dllfuncw( #dll, "DoFile", "myunicode.py" ); $result = dllfuncstrw( #dll, "GetStrVar", "result" ); message($result); #_ = dllfuncw( #dll, "DestroyScope" ); freedll(#dll); |