Search code examples
delphiunicodedelphi-2010delphi-2007

Converting Unicode Stream to String List in D2007


In a D2010 application I do

StringList.SaveToStream (MemStream, TEncoding.Unicode);

I then send this stream over the network to some client applications. This part of the code is fixed (I cannot change it):

Now I have a D2007 application that needs to receive this stream and convert it back to a string list. D2007 does not include Unicode support and the TEncoding class. How can I convert the stream into a string list? Something similar to

StringList.LoadFromStream (MemStream, TEncoding.Unicode)

in D2010...

Thanks for any help.


Solution

  • In Delphi 2007 you have few options:

    1. Use TWideStrings.
    2. Read the stream content into WideString variable and assign it value to the TStrings.Text property.