c#客户端SOCKET接收中文乱码
server
是c++写的执行sql语句从oracle数据库中查询内容通过socket发送;c++编译默认编码是unicode
_RecordsetPtr Rp=connect.GetRecordset(sql);
_variant_t varUserName;
string strUserName;
varUserName = Rp->GetCollect ("TICKETCODE");//票号
strUserName=strUserName+(char *)_bstr_t(varUserName);
strUserName=rtrim(strUserName);
send(clientSocket,strUserName.c_str(),strUserName.length(),0);
client:
c++写的windows窗体应用程序客户端接收不会乱码;
是c#写的WP客户端接收以后乱码 相关代码如下;
string response = "something";
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
socketEventArg.RemoteEndPoint = _socket.RemoteEndPoint;
socketEventArg.SetBuffer(new Byte[MAX_BUFFER_SIZE], 0, MAX_BUFFER_SIZE);
socketEventArg.Completed += new EventHandler(delegate(object s, So