Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: migrating from Delphi 6 With Indy 10 to XE7 with Indy 10


This question is answered.


Permlink Replies: 3 - Last Post: Mar 20, 2015 1:55 PM Last Post By: Remy Lebeau (Te...
al nickels

Posts: 173
Registered: 7/16/09
migrating from Delphi 6 With Indy 10 to XE7 with Indy 10  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 20, 2015 1:57 AM
I updated the original Indy in D6 to version 10 several years ago. Now I want to migrate my application from D6 to XE7 and would like some feedback on the best route to take. I usually send data using readln and writeln statements. The data is typically XML format. Since migrating to XE7 will include potential unicode data what is the best approach to take when reading and writing data? Will writeln and readln work in these cases or should I be using a different strategy to send unicode data between the tidtcpclient and tidtcpserver applications?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: migrating from Delphi 6 With Indy 10 to XE7 with Indy 10  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 20, 2015 10:48 AM   in response to: al nickels in response to: al nickels
al wrote:

I usually send data using readln and writeln statements.

I assume you are referring to the TIdIOHandler.ReadLn() and TIdIOHandler.WriteLn()
method.

Since migrating to XE7 will include potential unicode data what is the
best approach to take when reading and writing data?

You should set the TIdIOHandler.DefStringEncoding property to UTF-8, or specify
UTF-8 in the AByteEncoding parameter of ReadLn() and WriteLn(). You should
have been doing that even in your D7 code. In fact, there are also a TIdIOHandler.DefAnsiEncoding
property, and ASrcEncoding/ADestEncoding parameters on ReadLn() and WriteLn(),
to account for AnsiString in D2007 and earlier.

--
Remy Lebeau (TeamB)
al nickels

Posts: 173
Registered: 7/16/09
Re: migrating from Delphi 6 With Indy 10 to XE7 with Indy 10  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 20, 2015 1:47 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
al wrote:

I usually send data using readln and writeln statements.

I assume you are referring to the TIdIOHandler.ReadLn() and TIdIOHandler.WriteLn()
method.
That is correct. My mistake for not clarifying.

Since migrating to XE7 will include potential unicode data what is the
best approach to take when reading and writing data?

You should set the TIdIOHandler.DefStringEncoding property to UTF-8, or specify
UTF-8 in the AByteEncoding parameter of ReadLn() and WriteLn(). You should
have been doing that even in your D7 code. In fact, there are also a TIdIOHandler.DefAnsiEncoding
property, and ASrcEncoding/ADestEncoding parameters on ReadLn() and WriteLn(),
to account for AnsiString in D2007 and earlier.

I will veryfy the syntax for my D6 version and hopefully it was supported in that version of indy 10 that I have been using. I gather from your response that the tidiohandler.readln and writeln are acceptable.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: migrating from Delphi 6 With Indy 10 to XE7 with Indy 10
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 20, 2015 1:55 PM   in response to: al nickels in response to: al nickels
al wrote:

I gather from your response that the tidiohandler.readln
and writeln are acceptable.

In general, yes, provided the XML you are sending does not have any line
breaks in its data, and that the client and server are using the same encoding
when converting the XML string to bytes and back. Remember, sockets don't
know anything about strings, only about bytes. In a Unicode environment,
it is very important that you manage string<->byte conversions correctly.
In an Ansi environment, it is still important, but it is also easier to
get away with not paying attention to it (which is why many people get into
trouble when they migrate from Ansi to Unicode).

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02