一个unicode字符串,转换成ANSI字符串以实现public static string UnicodeToAscii(string paramstr)
{
if (paramstr.Length > 0)
{
byte[] array = System.Text.Encoding.ASCII.GetBytes(paramstr);
string str = null;
for (int i = 0; i < array.Length; i++)
{
int asciicode = (int)(array[i]);
str += Convert.ToString(asciicode);
}
return str;
}
else
{
throw new Exception("Unciode Code is not valid.");
}
}如何再将上面的 str 转回来呢,
求详细代码,立马结贴
{
if (paramstr.Length > 0)
{
byte[] array = System.Text.Encoding.ASCII.GetBytes(paramstr);
string str = null;
for (int i = 0; i < array.Length; i++)
{
int asciicode = (int)(array[i]);
str += Convert.ToString(asciicode);
}
return str;
}
else
{
throw new Exception("Unciode Code is not valid.");
}
}如何再将上面的 str 转回来呢,
求详细代码,立马结贴
解决方案 »
- [求助]向新的tabpages上添加webbrowser的问题???
- 关于 Thread.Sleep(Timeout.Infinite) 唤醒
- 如何获取本地IP、子网掩码、网关以及DNS呢??并能进行修改
- 在winform下,怎样设定某个网站的cookie
- c# 读取 远程 服务器上 的XML
- 如果更新DataTable中的某一行某一列的值。例如,我要更新DataTable 中第三行,第4列的值。如何写?
- 结构体中能不能定义变长的数组?
- 如何把dataSet中表的某列默认值设为变量
- 如何把窗口显示在最前方,请各位帮忙
- 各位前辈:《C#高级编程》(第二版)和《C# Primer Plus》这两本书中哪一本比较好?还有更好的书介绍吗?(UPers都有分!)
- 为什么我用socket连接,只能发送/接收一次数据,然后监听就自动关闭了?能不能无限监听
- 如何转换Datagridview某列,某单元个的数据类型?
{
return System.Text.Encoding.Unicode.GetString(System.Text.Encoding.ASCII.GetBytes(paramstr));
}