我最近将我的 Delphi 7 IDE 更改为 Delphi XE5(大变化)。我正在开发一个小型客户端/服务器应用程序,并且在尝试读取字符串时遇到问题。
我的代码:
Function TIOHandler.readString(Var data: String): Integer;
Var
byteReceived: Integer;
buff: Array Of Char;
Begin
byteReceived := 0;
Result := 0;
SetLength(buff, 255);
byteReceived := self.readBuffer(buff[0], SizeOf(buff));
If (byteReceived > 0) Then
Begin
SetLength(data, SizeOf(buff));
lstrcpyn(@data[1], @buff[0], SizeOf(buff));
Result := byteReceived;
End
Else If byteReceived = SOCKET_ERROR Then
Result := SOCKET_ERROR;
End;
Function TIOHandler.readBuffer(Var buffer; bufferSize: Integer): Integer;
Begin
Result := recv(self.ioSocket.aSock, buffer, bufferSize, 0);
End;
我得到了罕见的符号,看起来像是字符编码问题。谁能告诉我这是我错了。
最好的祝福。