Thanks DZ-Jay. I think we need to add a more complete function, ..just what to do if we need to encode (correctly) a full URL to use with HttpCli? ...It was my problem the last week!!
I have "hijacked", converted and shared a full URL encoder from Indy10.0.52 http://www.mcrenox.com.ar/uri.pas enjoy! David ----- Original Message ----- From: "DZ-Jay" <[EMAIL PROTECTED]> To: "ICS support mailing" <twsocket@elists.org> Sent: Sunday, February 12, 2006 11:13 AM Subject: Re: [twsocket] Encode URL > Hello: > The UrlEncode function is to encode strings to be included in URLs, by > escaping any invalid characters, not to encode complete URLs. You can > encode a complete URL, for example, when you want to send that URL as a > parameter in the QueryString, but this is not what you want to do: > > http://www.foo.com/bar.cgi? > url=http%3A%2F%2Fuser%3Apass%40www%2Esite%2Ecom%3A80%2Ffol%201%2Ffol%202 > %2Ffile%201%2Ejpg%3Fpar%3D1%23name > > What you must do in your case, is to encode each part that potentially > contains invalid characters, for example, directory or file names, or > parameter names and values. You want to encode them individually, > otherwise valid characters, such as '/' in paths and '=' or '&' in > parameters, will be wrongly encoded. For example: > > url := 'http://'+user+':'+pass+'@'+site+':'+port; > newurl := url > + '/' + UrlEncode(folder1) > + '/' + UrlEncode(folder2) > + '/' + UrlEncode(filename) > + '?' + UrlEncode(key[1]) + '=' + UrlEncode(value[1]) > + '&' + UrlEncode(key[2]) + '=' + UrlEncode(value[2]); > > // Add the anchor > If Anchor <> '' Then > newUrl := newUrl + '#' + Anchor; > End > > On Feb 10, 2006, at 17:46, David A. G. wrote: > >> Hello all >> >> I'm trying an HTTP-Get software but I found that UrlEncode (from >> IcsUrl.pas) >> is not working according the protocol. >> >> UrlEncode simply encodes all the URL without taking care of (parse) >> Protocol, Folders, File and Data. >> >> Example: >> >> http : // user:[EMAIL PROTECTED] site .com:80/fol 1/fol 2/file >> 1.jpg?par=1#name >> >> This URL must be encoded as: >> >> http : // www. site .com/fol%201/fol%202/file%201.jpg?par=1 >> >> but UrlEncode just makes: >> >> http%3A%2F%2Fuser%3Apass%40www%2Esite%2Ecom%3A80%2Ffol%201%2Ffol%202%2F >> file%201%2Ejpg%3Fpar%3D1%23name >> >> Obviously I cannot use the URL without encoding, but I cannot use the >> encode function provided. >> >> Any idea? >> Thanks, >> >> David >> >> -- >> To unsubscribe or change your settings for TWSocket mailing list >> please goto http://www.elists.org/mailman/listinfo/twsocket >> Visit our website at http://www.overbyte.be >> > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be