字节数组转成字符串成乱码,急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
代码如下:
private byte[] name=new byte[32];
win32API.API.ReadProcessMemory(this.openprocess, this.renwubase+this.NameOffset, out this.name[0], 32, 0);
string naemstr = System.Text.Encoding.Unicode.GetString(name);
this.nametext.Text = "角色名: " +naemstr;
文本框显示乱码,晕了!
------解决方案--------------------try
string naemstr = System.Text.Encoding.Default.GetString(name);
------解决方案--------------------private byte[] name=new byte[32];
win32API.API.ReadProcessMemory(this.openprocess, this.renwubase+this.NameOffset, out this.name[0], 32, 0);
string naemstr = System.Text.Encoding.Unicode.GetString(name);//这句换成string naemstr = System.Text.Encoding.Default.GetString(name); 试一下,看看是不是这个问题
this.nametext.Text = "角色名: " +naemstr;
------解决方案--------------------tring naemstr = System.Text.Encoding.GetEncoding( "utf-8 ").GetString(arrayByte,0,32);
------解决方案--------------------sorry,打错几个字
试试
string naemstr = System.Text.Encoding.GetEncoding( "utf-8 ").GetString(name,0,32);