Post Archive

› May 22, 2003

URL Encoding

  • Reported by Nate

How did this happen? How have I gotten by for this long without really understanding what URL encoding is? I mean, I knew that %20 is the equivalent of a space for urls, and I knew that   is the equivalent of a space for html entities, but somehow it escaped me that these are two different ways of doing things. I'm really quite embarrased.
Here's what spurred me to learn:
I found references to various older bookmarklets on webgraphics on a post at scriptygoddess. Part of the post mentioned something about the code looking messed up. I check. Sure enough it is. Maybe it's because I installed SmartyPants after those posts were written? Re-Read John Gruber's info about SmartyPants. Note that SmartyPants parsing can be escaped by <pre>, <code>, <kbd>, or <script>. Wrap <pre> around the bookmarklet links. Realize that wait - why do I need to wrap these links when all the funkyness is happening between the neat delimiters of href double quotes?
Well the answer is: SmartyPants isn't a bloated HTML parsing application, and, unlike this device it has no telekinetic powers to detect invalid url entities placed in bookmarklet code. With proper URL encoding none of my problems occur, and no pre tags are needed.
So I found a handy page that explains all that I didn't know about URL encoding and was afraid to ask: over on this page at blooberry. Note: the bottom of the page includes a very handy URL encoder/decoder. Hopefully this information will help someone, anyone, and the embarasment will be worth it.

Comments