Guest User

Untitled

a guest
Jan 23rd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.45 KB | None | 0 0
  1. aHasCharsToEncode := False;
  2.     for i := 1 to Length(s) do begin
  3.         c := s[i];
  4.         if (c = '%') or (c < ' ') then begin
  5.             aHasCharsToEncode := True;
  6.             break;
  7.         end;
  8.     end;
  9.     if not aHasCharsToEncode then begin
  10.         Result := s;
  11.         exit;
  12.     end;
  13.     sb.Init;
  14.     for i := 1 to Length(s) do begin
  15.         c := s[i];
  16.         if (c = '%') or (c < ' ') then begin
  17.             sb.Add('%' + IntToHex(Ord(c), 2));
  18.         end
  19.         else begin
  20.             sb.Add(c);
  21.         end;
  22.     end;
  23.     Result := sb.Value;
Add Comment
Please, Sign In to add comment