string clientCommand = "";
try
{
clientCommand = System.Text.Encoding.UTF8.GetString(buffer);//转换接收的数据,数据来源于客户端发送的消息
if (clientCommand.Contains("%7C"))//从Android客户端传递部分数据
clientCommand = clientCommand.Replace("%7C", "|");//替换UTF中字符%7C为|
}
------解决方案--------------------
buffer 是byte[]类型的吧,是不是可以改成这样?
我不了解C#,楼主试试吧,如果错了请忽略
String clientCommand = "";
try {
clientCommand = new String(buffer,"utf-8");
if(clientCommand.contains("%7C")){
clientCommand.replace("%7C", "
------解决方案--------------------
");
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}