Link to home
Start Free TrialLog in
Avatar of LeTay
LeTay

asked on

Move a string to a TStringStream and vice-versa

What is the correct way to move the content of a string to a TStringStream and vice-versa
Also, I suppose that the string should not a declared unicode but ... ?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LeTay
LeTay

ASKER

Many thanks for your quick answer, sinisav
It is "normal" that the string (sResult in your example) is unicode ?
Unicode means a even number of bytes so what happens if the stream contains an odd number of bytes ?
Thanks
As far I can see (in source :-) it is irrelevant what type of string is. Internally all goes with byte operation. If you put unicode string then you must read as unicode, same with ansistring. What version of Delphi you have? In newer Delphi (XEx) there is Encoding property which tells you what type of string is on, or when you before you write to stream set this prop. to right value.