-1

Possible Duplicate:
Standard URL encode function?

I need to transofrm a Delphi string (like TEdit.Caption) in a "url capable" string.

I need this because I will open google maps programmatically like in TEdit I write "High Street, Sydney"

and then i would like to open the browser at maps.google.com/maps?q=High+Street+Sidney

Is there a ready function to do this, also to parse accents?

Community
  • 1
  • 1
UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
  • 1
    @Cosmin Prund: +1 and more specifically I would pick the answer from Stijn Sanders (use InternetCanonicalizeUrl function) – Remko Nov 11 '11 at 14:39
  • @TLama, the OP wants to open a web browser with text based on what's in the edit box. That's URL encoding, even if the OP didn't know the name (if the OP knew the name, google would have solved the problem). – Cosmin Prund Nov 11 '11 at 14:43

1 Answers1

3

You can add IdURI unit from Indy to your uses clause, and use TIdURI.URLEncode() method to encode a URL, and TIdURI.Decode() to decode an encoded URL to a normal string.

vcldeveloper
  • 7,399
  • 2
  • 33
  • 39
  • I agree with all the comments made here, i tried with EncodeUrl and it works. I was mislead to '+' because the link generated by google is made with + and not with %20, anyway with %20 is ok, and I can even leave commas since google maps behave well even if commas are in the url. – UnDiUdin Nov 11 '11 at 15:15