Sometimes you just need to URL encode a string (URLEncodedFormat() in CF, or urlencode() in PHP), and not actually make a HTTP request. Here’s a simple library for you to use, that I wrote for my OAuth actionscript lib.

Attached is URLEncoding.as for your enjoyment.

Help make me popular:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Pownce
  • Slashdot
  • StumbleUpon

This entry was posted on Monday, April 28th, 2008 at 4:20 pm and is filed under Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

6 Responses to “URL Encoding in Actionscript”

  1. Nick Schneble on May 6th, 2008 at 6:32 pm

    Couldn’t you just use escape() instead?

    http://livedocs.adobe.com/flex/3/langref/package.html#escape()

  2. Shan on May 6th, 2008 at 9:05 pm

    Yep, you can. I didn’t find that until about a day after I wrote this.

  3. Nick Schneble on May 6th, 2008 at 11:24 pm

    That ALWAYS seems to happen :)

    Still, nice work!

  4. coldpizza on October 16th, 2008 at 8:25 am

    How about HTML-escape as opposed to URL-escape?

    That is, I want to convert as string like this:

    to something like this:

    “<a href=’http://www.google.com/search?hl=en&q=as3+escape’>”

    Looks like there is no build-it method. Or is there?

  5. coldpizza on October 16th, 2008 at 8:31 am

    oops, there is a bug in this blog - it should not linkify escaped html entities; and note, this is a potential security threat!

    ok, so here is my original string (spaces replaced with underlines):
    ___

    and this is what i want to get:
    __<a_href=’http://www.google.com/search?hl=en&q=as3+escape’>__

  6. coldpizza on October 16th, 2008 at 8:34 am

    wow, never thought wordpress is so crappy at this, it does not do decent HTML-escaping — ironically, just the thing that was focusing on..

Leave a Reply