If you are familiar with Ruby standard library then you probably know these two methods: URI.escape and CGI.escape. But turns out they are slight different and conforms to different specifications. Let’s see what are the key differences between them.

URI.escape method follows RFC 2396 also know as “Uniform Resource Identifiers(URI): Generic Syntax”. Some developers have some trouble using this escaping method.

I won’t go into the details of each specification but the TLDR; is that it doesn’t cover some characters. In other words, this method does not produce the same results of the encode URI JavaScript function.

If you need…

Rainer Borene

Programmer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store