Hallo,
wenn man nicht gerade nach dem Zeichen #0 suchen möchte, dann dürfte auch folgende Routine funktionieren:
Delphi-Quellcode:
function ReduceMultipleChars (const s: string; c: Char = ' '): string;
var
pRead, pEnd, pWrite : PChar;
begin
pRead := PChar(s);
pEnd := pRead + Length(s);
SetLength (Result, Length(s));
pWrite := PChar(Result);
while (pRead <> pEnd) do
begin
repeat
pWrite^ := pRead^;
Inc (pRead);
Inc (pWrite);
until ((pRead[-1] = c) or (pRead = pEnd));
while (pRead^ = c) do
Inc (pRead);
end;
SetLength (Result, pWrite - PChar(Result));
end;
Frohe Weihnachten!