Re: URLEncode vs ParamsEncode

Giganews Newsgroups
Subject: Re: URLEncode vs ParamsEncode
Posted by:  Remy Lebeau (Indy Team) (no.spam@no.spam.com)
Date: Mon, 11 Jun 2007

"Gloria" <gloria.…@gmail.com> wrote in message
news:CDC2EC7AED28E340gloria.…@gmail.com...

> Here is a simple program, using URLEncode and ParamsEncode
> to prepare http message. But I find the results are not the same!

They are not supposed to be.  By design, URLEncode() and
ParamsEncode() do not encode all of the same characters.

>  StringA  := 'http://?/';
>  UTF8Value := utf8Encode(StringA);

Which version of Delphi are you using?  Are you compiling for Win32 or
.NET?

>  showmessage( TidURI.ParamsEncode(UTF8Value) );  { result is
"http://%E4%B8?/" }
>  showmessage( TidURI.URLEncode(UTF8Value) );  { result is
"http://%E4%B8%80/" }

ParamsEncode() does not encode character $80, but URLEncode() does
when in the pat hor document section of the URL.

There is obviously something else in your string that you are not
showing here.  The original string you showed is fully within the
ASCII range and thus should not have been altered at all when
UTF-encoded, but it was nontheless.  So obviously the '?' is not the
original character that you are intending to use.  The fact that it is
getting UTF-encoded suggests you are trying to use Unicode characters
in your URLs, which you can't do as the URL protocol is Ansi-based,
like most other Internet protocols are.

Gambit

Replies

None

In response to

URLEncode vs ParamsEncode posted by Gloria on Wed, 6 Jun 2007