private void utf16(object sender, EventArgs e)
{
edit.code = "utf-16";
Invalidate();
}
|
private void utf8(object sender, EventArgs e)
{
edit.code = "utf-8";
Invalidate();
}
|
private void jis(object sender, EventArgs e)
{
edit.code = "Shift_JIS";
Invalidate();
}
|
private void none(object sender, EventArgs e)
{
edit.code = string.Empty;
Invalidate();
}
|
using System.Text;
public string code; //文字コード
Encoding enc;
|
public Edit()
{
pos = 0;
code = string.Empty;
}
|
public string View(string str)
{
int i,j,k;
byte[] wt = new byte[16];
str = "";
for(i=0; i<leng; i+=16)
{ j = leng-i;
if (j > 16) j = 16;
for(k=0; k<16; k++) wt[k]= 0;
for(k=0; k<j; k++) wt[k]= byt[i+k];
// オフセット
k = (pos+i) / 2;
str += k.ToString("X4");
str += ": ";
// 16進
for(k=0; k<j; k++)
{ str+= wt[k].ToString("X2");
if (k % 4 == 3) str += " ";
}
for(; k<16; k++)
{ str += " ";
if (k % 4 == 3) str += " ";
}
// 文字
if (code == string.Empty)
str += " ........";
else
{ str += " ";
enc = Encoding.GetEncoding(code);
string wstr = enc.GetString(wt);
wstr = wstr.Replace("\r", ".");
wstr = wstr.Replace("\n", ".");
str += wstr;
}
str+= " ";
str+= "\r\n";
}
return str;
}
|
[Previous Chapter ↑] Edit Object Class