ITextWriter.Encoding

Syntax

Encoding: CodePage;

Description

The Encoding property determines a text encoding for writing into a file.

Example

Sub UserProc;
Var
    f: IFileStream;
    TxtWriter: ITextWriter;
Begin
    f := New FileStream.Create("c:\File.txt", FileOpenMode.Create, FileShare.Exclusive);
    TxtWriter := New TextWriter.Create(f);
    TxtWriter.Encoding := CodePage.UTF8;
    TxtWriter.WriteLnString("Welcome!");
    TxtWriter.Flush;
    Dispose f;
End Sub UserProc;

On executing the example a new text file File.txt is created. The character string encoded in Unicode UTF-8 is saved to the file.

See also:

ITextWriter