TSubstringList.Encoding Property

property Encoding: TEncoding read FEncoding;

The encoding of the last load: the one its byte order mark named, else the one it was given, else DefaultEncoding; nil before the first load. SaveToFile and SaveToStream without an encoding write in it.

Returns: TEncoding

Examples

The encoding a byte order mark names.

uses Substr, System.SysUtils, System.Classes;

procedure Example;
var List: TSubstringList;
    Stream: TBytesStream;
begin
    List := TSubstringList.Create(2);
    Stream := TBytesStream.Create;
    try
        Assert(List.Encoding = nil);
        List.Add('a');
        List.SaveToStream(Stream, TEncoding.UTF8);
        Stream.Position := 0;
        List.LoadFromStream(Stream);
        Assert(List.Encoding = TEncoding.UTF8);
    finally
        Stream.Free;
        List.Free;
    end;
end;
See Also: TSubstringList.DefaultEncoding, TSubstringList.LoadFromStream, TSubstringList.LoadFromStream