Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndyTextEncoding_8Bit Issue?
#1
Greetings,

I am trying to convert the TCP classes in an existing Delphi 5 application to Indy so that I can add SSL. The application sends text as well as binary commands to a server as strings over a TCP connection. The commands have a wide range of values outside of the normal ASCII character range (0x80 to 0xFF). I have configured the IOHandler to use IndyTextEncoding_8Bit encoding, however it appears that values from 0x80 to 0x9F are still being sent as 0x3F (the '?' which I believe is sent when using sending non-ASCII chars with ASCII encoding). I have created a simple test client/server app to recreate the behavior that I'm seeing. Here is the relevant client code:

Code:
constructor TestClient.Create();
begin
  inherited Create;
  TCPC := TIdTCPClient.Create();
  TCPC.ConnectTimeout := 5000;
  TCPC.Host := 'localhost';
  TCPC.Port := 5000;
  try
    TCPC.Connect;
    TCPC.IOHandler.DefStringEncoding := IndyTextEncoding_8Bit;
  except
    on Exception do begin
      ShowMessage('error occurred during connect');
    end;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
  var s: string;
begin
  s := #128;
  RunClient.TCPC.IOHandler.Write(s);
end;

The server has also been configured to use IndyTextEncoding_8Bit encoding and is receiving the expected hex values when sending data outside of the 0x80 to 0x9F range. I have also verified with Wireshark that that 0x3F is being sent by the client when running the above code.

Is there a different encoding type that I should be using? or some issue with the 0x80 to 0x9F value range? perhaps an incompatibility when using Indy with Delphi 5? I've been pulling my hair out and I'm hoping that I'm missing something obvious (I'm new to Delphi so that could easily be the case!).

-Ed
Reply


Messages In This Thread
IndyTextEncoding_8Bit Issue? - by eddie1473 - 01-09-2023, 03:49 AM
RE: IndyTextEncoding_8Bit Issue? - by rlebeau - 01-09-2023, 07:06 PM
RE: IndyTextEncoding_8Bit Issue? - by eddie1473 - 01-10-2023, 02:57 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)