2006. április 14., péntek

Load DOS text in a RichEdit


Problem/Question/Abstract:

Load OEM file (any DOS edited file) in a RichEdit.

Answer:

Use the following code, that translates the text through the OemToAnsiBuff function:


procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
  linea: PChar;
  txt: TStringList;
begin
  txt := TStringList.Create;
  try
    txt.LoadFromFile('c:\Fichero\a\leer.txt');
    for i := 0 to txt.Count - 1 do
    begin
      linea := PChar(txt.strings[i]);
      OemToAnsiBuff(linea, linea, strlen(linea));
    end;
    RichEdit1.Lines.AddStrings(txt);
  finally
    txt.Free;
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése