function URLEncode(InStr: string): string;<br>var<br> intSourceLen: integer;<br> intForLoop: integer;<br> strTemp: string;<br> strSource: string;<br> strDestCode: string;<br> charTemp: char;<br>begin<br> strSource := UTF8Encode(InStr);<br> strDestCode := '';<br> intSourceLen := length(strSource);<br> for intForLoop := 1 to intSourceLen do<br> begin<br> charTemp := strSource[intForLoop];<br> if charTemp = ' ' then<br> begin<br> strDestCode := strDestCode + '+';<br> end else if charTemp = #13 then<br> begin<br> strDestCode := strDestCode + '%0D%0A';<br> end else if (charTemp < '0') or ((charTemp < 'A') and (charTemp > '9')) or<br> ((charTemp > 'Z') and (charTemp < 'a')) or (charTemp > 'z') then<br> begin<br> strTemp := inttohex(ord(charTemp), 2);<br> strDestCode := strDestCode + '%' + strTemp;<br> end else<br> begin<br> strDestCode := strDestCode + charTemp;<br> end;<br> end;<br> Result := strDestCode;<br>end;