Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

How to use Unicode text in streams?

  Alt 12. Okt 2010, 12:25
Delphi-Version: 2010
How to use Unicode strings in streams? I need to save strings in binary stream - for this I'm using TStringStream, but string are stored as ASCII.

Delphi-Quellcode:
var
  S: TStringStream;
begin
  S := TStringStream.Create;
  S.Encoding.UTF8;
  S.WriteString('');
  S.SaveToFile('C:\0.txt');
  S.Free;

  S := TStringStream.Create;
  S.Encoding.UTF8;
  S.LoadFromFile('C:\0.txt');
  Caption := S.DataString;
  S.Free;
end;
  Mit Zitat antworten Zitat