Encoding: CodePage;
The Encoding property determines a text encoding to read from a file.
In order text is displayed correctly, the encoding determined by the Encoding property must match with that of the saved file.
Executing the example requires the text file: C:\file.txt.
Add a link to the IO system assembly.
Sub UserProc;
Var
File1: IFileInfo;
TextR: ITextReader;
s: String;
Begin
File1 := New FileInfo.Attach("C:\file.txt");
If File1.Exists Then
TextR := File1.OpenTextReader;
TextR.Encoding := CodePage.ANSI_Cyrillic;
s := TextR.ReadString(10);
End If;
Debug.WriteLine(s);
Dispose File1;
End Sub UserProc;
After executing the example the console window displays the first 10 characters in the ANSI_Cyrillic encoding from the file.txt file.
See also: