Einzelnen Beitrag anzeigen

Namenloser

Registriert seit: 7. Jun 2006
Ort: Karlsruhe
3.724 Beiträge
 
FreePascal / Lazarus
 
#8

Re: Ascii Zeichen aus einer Datei entfernen

  Alt 25. Mai 2009, 13:51
Zitat von DBasner:
Ja das hatte ich wohl etwas falsch ausgedrückt. Aber ich denke das man erkannt hat worum es geht.
Nicht wirklich. Was heißt für dich "Text"? Buchstaben von A-Z? Und vergiss nicht, dass "Ascii-Zeichen" auch in Binärdaten vorkommen.

Delphi-Quellcode:
function FilterChars(const s: string; Allowed: Set of Char): string;
var
  LIndex: integer;
  i: integer;
begin
  SetLength(result,length(s));
  LIndex := 0;
  for i := 1 to Length(s) do
  begin
    if (s[i] in Allowed) then
    begin
      inc(LIndex);
      result[LIndex] := s[i];
    end;
  end;
  SetLength(result,LIndex);
end;

function FilterText(const s: string): string;
begin
  result := StripChars(s, ['A'..'Z','a'..'z']);
end;
So könnte das funktionieren, wenn ich dich richtig verstehe.
  Mit Zitat antworten Zitat