| View previous topic :: View next topic |
| Author |
Message |
Hamid Guest
|
Posted: Mon Apr 10, 2006 12:03 pm Post subject: Using URLEncode |
|
|
How can I use the URLEncode method of TIdURI component?
I am using the method like this:
AnsiString string;
TIdURI *idUri = new TIdURI("");
string = idUri->URLEncode(__classid(TIdURI), "http://domain.com?text=text1 + text2");
But it returns the same character as the input string. It does not encode it. Why? |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Apr 10, 2006 7:03 pm Post subject: Re: Using URLEncode |
|
|
"Hamid" <hrz_mir (AT) Yahoo (DOT) com> wrote in message
news:443a3c6c$1 (AT) newsgroups (DOT) borland.com...
| Quote: | TIdURI *idUri = new TIdURI("");
string = idUri->URLEncode(__classid(TIdURI), "http://domain.com?text=text1
+ text2"); |
URLEncode is a static method, you do not need to create an instance of the
class in order to use it:
string = TIdURI::URLEncode(__classid(TIdURI),
"http://domain.com?text=text1 + text2");
| Quote: | But it returns the same character as the input string. It does not encode
it. Why? |
Which version of Indy are you actually using? The debate over whether
spaces are encoded or not has been re-visited several times before. Some
versions of Indy did encode spaces. Some did not. The current snapshot of
Indy 9 does.
Gambit |
|
| Back to top |
|
 |
Hamid Guest
|
Posted: Tue Apr 11, 2006 7:03 am Post subject: Re: Using URLEncode |
|
|
Thanx for your reply. In fact, I had a code written in BCB6.0 (Indy 8.0) and I am upgrading it to BDS2006. I am calling the Get method of the TIDHttp and I have to encode the url. In BCB6.0 an instance of TNMUrl did it which is not supported any more:
nmUrl->InputString = myUrl + myParameters;
encodedUrl = nmUrl->Encode;
and in BDS2006 (Indy 10) I changed my code to:
encodedUrl = TIdURI::URLEncode(__classid(TIdURI), "http://domain.com?text=text1 + text2");
Maybe I am selecting and using the URLEncode method mistakenly. |
|
| Back to top |
|
 |
Hamid Guest
|
Posted: Tue Apr 11, 2006 7:03 am Post subject: Re: Using URLEncode |
|
|
| Apparently, Indy 9 has few bugs. Is it possible to install and use Indy 9 in BDS2006? |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 11, 2006 7:03 am Post subject: Re: Using URLEncode |
|
|
"Hamid" <hrz_mir (AT) Yahoo (DOT) com> wrote in message
news:443b411a$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I had used the static method before getting an instance and it did not
work. |
Just saying it does not work says nothing about the actual problem you have
with it.
| Quote: | Which version of Indy are you actually using?
I am using Indy 10 integrated with BDS2006.
|
Did you upgrade to the latest 10.1.5 snapshot? In any case, URLEncode()
does encode spaces in Indy 10. So what EXACTLY are you having a problem
with? Please provide an actual example of what you are seeing, and you are
expecting to see instead.
Gambit |
|
| Back to top |
|
 |
Hamid Guest
|
Posted: Tue Apr 11, 2006 7:03 am Post subject: Re: Using URLEncode |
|
|
I had used the static method before getting an instance and it did not work.
string = TIdURI::URLEncode(__classid(TIdURI),
"http://domain.com?text=text1 + text2");
| Quote: | Which version of Indy are you actually using?
|
I am using Indy 10 integrated with BDS2006. |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 11, 2006 8:03 am Post subject: Re: Using URLEncode |
|
|
"Hamid" <hrz_mir (AT) Yahoo (DOT) com> wrote in message
news:443b46c0$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Is it possible to install and use Indy 9 in BDS2006?
|
BDS 2006 ships with both Indy 9 and 10. But Indy 10 is not officially
available for C++ at the moment.
Gambit |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 11, 2006 8:03 am Post subject: Re: Using URLEncode |
|
|
"Hamid" <hrz_mir (AT) Yahoo (DOT) com> wrote in message
news:443b4951$1 (AT) newsgroups (DOT) borland.com...
| Quote: | In fact, I had a code written in BCB6.0 (Indy 8.0) and I am upgrading it
to BDS2006. |
That is a very large leap.
| Quote: | I am calling the Get method of the TIDHttp and I have to encode the url.
|
Again I ask, what is the EXACT problem you are having with it? What you do
EXPECT it to return? What does it ACTUALLY return?
Gambit |
|
| Back to top |
|
 |
Hamid Guest
|
Posted: Tue Apr 11, 2006 9:03 am Post subject: Re: Using URLEncode |
|
|
| Quote: | Again I ask, what is the EXACT problem you are having with it? What you do
EXPECT it to return? What does it ACTUALLY return?
|
I passed this string as input:
"http://domain.com?text=text1 + text2"
and it returns "http://domain.com?text=text1 + text2/" as output. No encoding for spcace and "+" sign. |
|
| Back to top |
|
 |
Hamid Guest
|
Posted: Tue Apr 11, 2006 9:03 am Post subject: Re: Using URLEncode |
|
|
I saw the both folders (Indy10 and Indy9) but in available packages of the project, only Indy 10 (Core and Protocoles) are available. How can I change them? The Include path can be shifted easily from Indy10 to Indy9, but which packages (bpl files) in the \Bin directory are for Indy9?
P.S. I have modified some headers of the Indy10 in order to use it without compile time errors. That's why I can use it in BCB2006.
thanx again. |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 11, 2006 6:04 pm Post subject: Re: Using URLEncode |
|
|
"Hamid" <hrz_mir (AT) Yahoo (DOT) com> wrote in message
news:443b6445$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I saw the both folders (Indy10 and Indy9) but in available
packages of the project, only Indy 10 (Core and Protocoles) are available.
|
Indy 10 uses three packages. There is a System package that is required
along with the Core and Protocols packages.
| Quote: | I have modified some headers of the Indy10 in order to use it without
compile time errors. |
C++ support is currently being worked on. Manual edits will not be needed
once it has been released.
Gambit |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 11, 2006 7:03 pm Post subject: Re: Using URLEncode |
|
|
"Hamid" <hrz_mir (AT) Yahoo (DOT) com> wrote in message
news:443b64ac$1 (AT) newsgroups (DOT) borland.com...
| Quote: | No encoding for spcace and "+" sign.
|
'+' is not supposed to be encoded in the query portion.of the URL.
As for the spaces, they are guaranteed to always be encoded, so there is no
way that they can be ignored.
As for the '/' being appended at the end of your URL, that is because you do
not have any '/' after the domain in your input URL. TIdURI expects that,
ie:.
"http://domain.com/?text=text1 + text2"
Gambit |
|
| Back to top |
|
 |
Hamid Guest
|
Posted: Tue Apr 11, 2006 7:03 pm Post subject: Re: Using URLEncode |
|
|
Thanx Remy,
and what do you think of URLEncode? Do you have the same problem when you try to use it?
I passed this string as input:
"http://domain.com?text=text1 + text2"
and it returns "http://domain.com?text=text1 + text2/" as output. No encoding for spcace and "+" sign.
Thanx again, |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 11, 2006 11:03 pm Post subject: Re: Using URLEncode |
|
|
"Hamid" <hrz_mir (AT) Yahoo (DOT) com> wrote in message
news:443bea81$1 (AT) newsgroups (DOT) borland.com...
| Quote: | and what do you think of URLEncode?
|
I already answered that.
Gambit |
|
| Back to top |
|
 |
Hamid Guest
|
Posted: Wed Apr 12, 2006 6:03 am Post subject: Re: Using URLEncode |
|
|
| Thanx. It worked. So how can I force the URLEncode to encode the special signes such as the "+" sign to "%2B"? |
|
| Back to top |
|
 |
|