---
title: "PHP hata Delphi?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/programmering/43987-php-hata-delphi"
topic: "Programmering"
topic_url: "https://www.webforum.nu/amne/programmering"
author: "Jontto"
published: "2002-05-17T14:01:55.000Z"
updated: "2002-05-19T21:45:16.000Z"
replies: 2
views: 226
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/programmering/43987-php-hata-delphi"
---

# PHP hata Delphi?

## #1 — Jontto, 2002-05-17T14:01Z

Började just programmera i Delphi (2 dagen på gång re'n), å funderade om man på något sätt kan "urldecoda" något som man har urlencodat med PHP och urlencoda text tillbaka oxå?

Tacksam för svar,
Jontto

Permalänk: https://www.webforum.nu/p/43987

## #2 — jt, 2002-05-19T21:28Z

Testa dessa funktioner.

function URLDecode(ASrc: string): string;
var
  i: integer;
  ESC: string\[2\];
  CharCode: integer;
begin
  Result := '';
  ASrc := StringReplace(ASrc, '+', ' ', \[rfReplaceAll\]);  {do not localize}
  i := 1;
  while i \<= Length(ASrc) do begin
    if ASrc *\<\> '%' then begin  {do not localize}
      Result := Result + ASrc
    *end else begin
      Inc(i); // skip the % char
      ESC := Copy(ASrc, i, 2); // Copy the escape code
      Inc(i, 1); // Then skip it.
      try
        CharCode := StrToInt('$' + ESC);  {do not localize}
        if (CharCode \> 0) and (CharCode \< 256) then begin
          Result := Result + Char(CharCode);
        end;
      except end;
    end;
    Inc(i);
  end;
end;

function URLEncode(ASrc: string): string;
const
  UnsafeChars = \['\*', '#', '%', '\<', '\>', '+'\];  {do not localize}
var
  i: Integer;
begin
  Result := '';
  for i := 1 to Length(ASrc) do begin
    if ASrc *\= ' ' then begin    {do not localize}
      Result := Result + '+';    {do not localize}
    end else if (ASrc *in UnsafeChars) or (ASrc *\>= #$80) then begin
      Result := Result + '%' + IntToHex(Ord(ASrc*), 2);  {do not localize}
    end else begin
      Result := Result + ASrc*;
    end;
  end;
end;*******

Permalänk: https://www.webforum.nu/p/679013

## #3 — PeW, 2002-05-19T21:45Z

Hade varit trevligt om man använder kodtaggarna när man postar kod... :OO

Permalänk: https://www.webforum.nu/p/679019

---

Tråden på webben: https://www.webforum.nu/amne/programmering/43987-php-hata-delphi
