String to Bytes:
Dim Bytes() As Byte = Encoding.Unicode.GetBytes(myString.ToCharArray())Bytes to String
Dim myString as string=Encoding.Unicode.GetString(Bytes)If you like to deal with Chinese, you need to choose Unicode.
Dim Bytes() As Byte = Encoding.Unicode.GetBytes(myString.ToCharArray())Bytes to String
Dim myString as string=Encoding.Unicode.GetString(Bytes)If you like to deal with Chinese, you need to choose Unicode.
private void button1_Click(object sender, System.EventArgs e)
{
byte[] bytes; string st="字符串1001101—*……%¥"; bytes=Encoding.Unicode.GetBytes(st); string st1=Encoding.Unicode.GetString(bytes); textBox1.Text=st1;
} :)
byte[] byteArr = System.Text.Encoding.Default.GetBytes(s);
s = System.Text.Encoding.Default.GetString(byteArr);
private void Button1_Click(object sender, System.EventArgs e)
{
StreamReader sr = new StreamReader(File1.PostedFile.InputStream,Encoding.Unicode); byte[] buff = new Byte[File1.PostedFile.InputStream.Length];
File1.PostedFile.InputStream.Read(buff,0,(int)File1.PostedFile.InputStream.Length);
string s = Encoding.Unicode.GetString(buff);
byte[] buff2 = Encoding.Unicode.GetBytes(s); Response.Write(BitConverter.ToString(buff));
Response.Write("<br>\n");
Response.Write(BitConverter.ToString(buff2));}
I tried on ASP.NET :)
anyway , TheAres(班门斧):
您的方法并不完善,因为用GB2312编码的时候就会出错,具体原因我也不知道:)