Board index » cppbuilder » Using URLEncode

Using URLEncode


2006-04-10 07:07:24 PM
cppbuilder85
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), "domain.com + text2");
But it returns the same character as the input string. It does not encode it. Why?
 
 

Re:Using URLEncode

"Hamid" < XXXX@XXXXX.COM >wrote in message
Quote
TIdURI *idUri = new TIdURI("");
string = idUri->URLEncode(__classid(TIdURI), "domain.com
+ 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),
"domain.com + 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
 

Re:Using URLEncode

I had used the static method before getting an instance and it did not work.
string = TIdURI::URLEncode(__classid(TIdURI),
"domain.com + text2");
Quote
Which version of Indy are you actually using?
I am using Indy 10 integrated with BDS2006.
 

{smallsort}

Re:Using URLEncode

"Hamid" < XXXX@XXXXX.COM >wrote in message
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
 

Re:Using URLEncode

Apparently, Indy 9 has few bugs. Is it possible to install and use Indy 9 in BDS2006?
 

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), "domain.com + text2");
Maybe I am selecting and using the URLEncode method mistakenly.
 

Re:Using URLEncode

"Hamid" < XXXX@XXXXX.COM >wrote in message
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
 

Re:Using URLEncode

"Hamid" < XXXX@XXXXX.COM >wrote in message
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
 

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.
 

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:
"domain.com + text2"
and it returns "domain.com + text2/" as output. No encoding for spcace and "+" sign.
 

Re:Using URLEncode

"Hamid" < XXXX@XXXXX.COM >wrote in message
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
 

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:
"domain.com + text2"
and it returns "domain.com + text2/" as output. No encoding for spcace and "+" sign.
Thanx again,
 

Re:Using URLEncode

"Hamid" < XXXX@XXXXX.COM >wrote in message
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:.
"domain.com/ + text2"
Gambit
 

Re:Using URLEncode

"Hamid" < XXXX@XXXXX.COM >wrote in message
Quote
and what do you think of URLEncode?
I already answered that.
Gambit
 

Re:Using URLEncode

Thanx. It worked. So how can I force the URLEncode to encode the special signes such as the "+" sign to "%2B"?