这个只能转英文,转汉字不行。
string s="abc"; byte[] byteData = Encoding.ASCII.GetBytes(s);
Stream Astream=new MemoryStream();
Astream.Write(byteData,0,byteData.Length);
Astream.Position = 0; byte[] bytes = new byte[1024];
int numBytesToRead = (int) Astream.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
int n = Astream.Read(bytes, numBytesRead, numBytesToRead);
if (n==0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
Astream.Close();
string b=Encoding.ASCII.GetString(bytes,0,numBytesRead);
string s="abc"; byte[] byteData = Encoding.ASCII.GetBytes(s);
Stream Astream=new MemoryStream();
Astream.Write(byteData,0,byteData.Length);
Astream.Position = 0; byte[] bytes = new byte[1024];
int numBytesToRead = (int) Astream.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
int n = Astream.Read(bytes, numBytesRead, numBytesToRead);
if (n==0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
Astream.Close();
string b=Encoding.ASCII.GetString(bytes,0,numBytesRead);
解决方案 »
- C# windows mobile 扫描条形码后如何自动执行扫描事件
- 请高手帮忙解决多个自定义控件滚动时闪烁的问题
- 使用WPF,如何做出如下效果的GridViewColumn
- 200分+送出去了,怎么就解决的呢?高分寻求视频播放问题!!!!!!!!!!!!!!!
- DATAgridview怎么在一列中加入 listbox!
- 主线程被卡死,鼠标等无法动作!请教各位哪里出问题了?
- C#怎么通过一个窗体的BUTTON按钮给另一个窗体的LISTVIEW添加一行
- .NET框架程序设计(修订版)谁能提供下载感谢!!!!!!!!!!
- Visual C# .NET 2003的改变
- 如何将一个DataSet按值传参?
- 一个很怪异的问题。
- 一个简单的问题,C#经验者进
改Encoding.Unicode试下~
string b = Encoding.GetEncoding("GB2312").GetString(bytes, 0, numBytesRead);
byte[] bytee = a.GetBytes("you");
foreach(byte by in butee)
Console.WriteLine(by);