public string Transtonormalcode(string source)
{
string transedstring = source;
byte[] sourcebyte=System.Text.Encoding.ASCII.GetBytes(source);
for(int i=0;i<sourcebyte.Length;i++)
{
if(sourcebyte[i]==16)//如果是特殊的命令符号
{
sourcebyte[i]=62;//那么修改成为大于号
}
else if(sourcebyte[i]==0x1c||sourcebyte[i]==0x1d)//如果是闪烁的字体,转换为空格
{
sourcebyte[i]=0x20;
}
}
transedstring = Encoding.ASCII.GetString( sourcebyte, 0, sourcebyte.Length );
return transedstring;
}
该段代码是为了替换一些特殊的字符,但是转回去的时候中午字符都不正常了,请问如何解决。怎么才能把ascII码专程正常的中文
{
string transedstring = source;
byte[] sourcebyte=System.Text.Encoding.ASCII.GetBytes(source);
for(int i=0;i<sourcebyte.Length;i++)
{
if(sourcebyte[i]==16)//如果是特殊的命令符号
{
sourcebyte[i]=62;//那么修改成为大于号
}
else if(sourcebyte[i]==0x1c||sourcebyte[i]==0x1d)//如果是闪烁的字体,转换为空格
{
sourcebyte[i]=0x20;
}
}
transedstring = Encoding.ASCII.GetString( sourcebyte, 0, sourcebyte.Length );
return transedstring;
}
该段代码是为了替换一些特殊的字符,但是转回去的时候中午字符都不正常了,请问如何解决。怎么才能把ascII码专程正常的中文
解决方案 »
- 再求正则
- 架构问题
- 為什么我一觸發這段代碼,主頁的CSS樣式就全部都丟失了.頁面很難看.
- 急问```在线等
- VS2005远程调试问题!!
- 如果一个对象的属性(值类型)作为一个方法的参数,那么在方法里面能不能取得传入属性的特性?
- 使用C#基于TCP/IP嵌套字写的FTP客户端程序为什么有的跨网段可以访问OpenVMS 的lgFTP有的不可以(DELPHI的控件是可以访问的)
- 为什么System.Diagnostics.Process.star()执行不成功?
- 求C#编写的驾校信息系统的源码
- 我的vs2002中文企业版 一debug就死掉了,怎么回事。
- 请问如何进行团队开发???????????????????
- COM读数据出现乱码
transedstring = Encoding.ASCII.GetString( sourcebyte, 0, sourcebyte.Length );
----------------------------------------------改为
byte[] sourcebyte = System.Text.Encoding.UTF8.GetBytes(source);
transedstring = Encoding.UTF8.GetString(sourcebyte, 0, sourcebyte.Length);
{
return source.Replace('\x10', '>').Replace('\x1c', ' ').Replace('\x1d', ' ');
}