Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Wee(str: string): string;
- var
- h, i: Integer;
- s, r: string;
- begin
- if (Length(str) > 1) then
- begin
- s := '0'#0 'a'#7 'b'#8 't'#9 'n'#10 'f'#12 'r'#13 'e'#27;
- h := (Length(s) div 2);
- r := #0'[R%B%S]'#0;
- Result := Replace(str, '\\', r, [rfReplaceAll]);
- for i := 1 to h do
- Result := Replace(Result, ('\' + s[((i * 2) - 1)]), s[(i * 2)], [rfReplaceAll]);
- Result := Replace(Result, r, '\', [rfReplaceAll]);
- end;
- end;
- function Wee2(str: string): string;
- var
- b, h, i, l, p, c, q: Integer;
- s, r, t, z: string;
- begin
- Result := '';
- if (Length(str) > 1) then
- begin
- s := '0abtnfre'#0#7#8#9#10#12#13#27;
- h := (Length(s) div 2);
- r := #0'[R%B%S]'#0;
- c := 0;
- p := 0;
- b := 1;
- z := Replace(str, '\\', r, [rfReplaceAll]);
- l := (Length(z) - 1);
- repeat
- p := (p + 1);
- if (z[p] = '\') then
- begin
- q := (p + 1);
- for i := 1 to h do
- if (z[q] = s[i]) then
- begin
- if (c > 0) then
- Result := (Result + Copy(z, b, c));
- Result := (Result + s[(i + h)]);
- p := q;
- b := (p + 1);
- c := -1;
- Break;
- end;
- end;
- c := (c + 1);
- until (p >= l);
- Result := (Result + Copy(z, b, (c + 1)));
- Result := Replace(Result, r, '\', [rfReplaceAll]);
- end;
- end;
- var
- t: Integer;
- str, data: string;
- begin
- ClearDebug;
- data := 'Test \r\n Wtf \\n Wee\r\n';
- for t := 0 to 13 do
- data := (data + data);
- WriteLn(Length(data));
- t := GetSystemTime;
- str := Wee2(data);
- WriteLn('Wee2 - ' + IntToStr(Length(str)) + ': ' + IntToStr(GetSystemTime - t) + ' ms. [' + MD5(str) + ']');
- str := '';
- t := GetSystemTime;
- str := Wee(data);
- WriteLn('Wee - ' + IntToStr(Length(str)) + ': ' + IntToStr(GetSystemTime - t) + ' ms. [' + MD5(str) + ']');
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement