• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 8 رای - 2.25 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: سورس کد اینکود و دیکود url (دلفی)
حالت موضوعی
#1
با سورس زیر url یا ادرس همان سایت مورد نظر خودمون رو اینکود و یا دیکد کنیم.

تابع اینکود :

کد:
function URLEncode(const S: string; const InQueryString: Boolean): string;
var
  Idx: Integer; // loops thru characters in string
begin
  Result := '';
  for Idx := 1 to Length(S) do
  begin
    case S[Idx] of
      'A'..'Z', 'a'..'z', '0'..'9', '-', '_', '.':
        Result := Result + S[Idx];
      ' ':
        if InQueryString then
          Result := Result + '+'
        else
          Result := Result + ' ';
      else
        Result := Result + '%' + SysUtils.IntToHex(Ord(S[Idx]), 2);
    end;
  end;
end;

تابع دیکود :

کد:
function URLDecode(const S: string): string;
var
  Idx: Integer;   // loops thru chars in string
  Hex: string;    // string of hex characters
  Code: Integer;  // hex character code (-1 on error)
begin
  // Intialise result and string index
  Result := '';
  Idx := 1;
  // Loop thru string decoding each character
  while Idx <= Length(S) do
  begin
    case S[Idx] of
      '%':
      begin
        // % should be followed by two hex digits - exception otherwise
        if Idx <= Length(S) - 2 then
        begin
          // there are sufficient digits - try to decode hex digits
          Hex := S[Idx+1] + S[Idx+2];
          Code := SysUtils.StrToIntDef('$' + Hex, -1);
          Inc(Idx, 2);
        end
        else
          // insufficient digits - error
          Code := -1;
        // check for error and raise exception if found
        if Code = -1 then
          raise SysUtils.EConvertError.Create(
            'Invalid hex digit in URL'
          );
        // decoded OK - add character to result
        Result := Result + Chr(Code);
      end;
      '+':
        // + is decoded as a space
        Result := Result + ' '
      else
        // All other characters pass thru unchanged
        Result := Result + S[Idx];
    end;
    Inc(Idx);
  end;
end;
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  سورس کد انتقال فایل به سطل اشغال ( دلفی) Amin_Mansouri 1 5,457 10-08-2022، 06:21 PM
آخرین ارسال: sonusood
  سورس بدست اوردن کلیپ برد ( دلفی ) Amin_Mansouri 1 7,401 10-08-2022، 05:49 PM
آخرین ارسال: sonusood
  دلفی و تلگرام h_mohamadi 2 4,614 04-24-2017، 12:14 AM
آخرین ارسال: shilanaseri
  رسم نمودار در اکسل از طریق دلفی Saeed7007 1 6,392 08-14-2014، 06:11 PM
آخرین ارسال: Amin_Mansouri
  سورس کد بدست اوردن اطلاعات هارد دیسک (دلفی) Amin_Mansouri 1 8,368 07-30-2014، 05:45 PM
آخرین ارسال: dehqan_mehdi
  ۳۵۰ سورس کد دلفی (دلفی رو از ابتدا تا حرفه ای شدن یاد بگیرید) Amin_Mansouri 11 31,358 01-31-2014، 04:27 PM
آخرین ارسال: Amin_Mansouri
  بارگذاری و یا نمایش تصویر فرمت jpg (دلفی) Amin_Mansouri 2 10,431 08-23-2013، 10:06 PM
آخرین ارسال: mo_coders
  بدست اوردن لیست درایورهای موجود بر روی سیستم توسط API (دلفی) Amin_Mansouri 0 4,780 08-17-2013، 09:56 AM
آخرین ارسال: Amin_Mansouri
  دانلود سورس کد استفاده از نقشه گوگل در دلفی Amin_Mansouri 0 6,738 08-17-2013، 09:44 AM
آخرین ارسال: Amin_Mansouri
  سورس کد شناسایی مرورگرهای نصب شده بر روی سیستم عامل (دلفی) Amin_Mansouri 0 4,985 08-17-2013، 09:35 AM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 1 مهمان