Reputation: 16612
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.
Upvotes: 2
Views: 3116
Reputation: 24483
Edit: since you cannot change your Delphi 2010 code, I'd use the TWideStrings
class from the WideStrings
unit in Delphi 2007: that class supports unicode strings.
Note that when encoding in Delphi 2010, you will find a BOM (byte order mark) at the start of the stream.
I would save the stream in Delphi 2010 as UTF8 (TEncoding.UTF8), then in Delphi 2007 use the function UTF8Decode(const S: UTF8String): WideString;
(docs) from the System
unit.
--jeroen
Upvotes: 2
Reputation: 7750
In Delphi 2007 you have few options:
Upvotes: 4