0

I am referencing an API for developing an application for a social platform called Mixi. I am stuck at a point where it says the following: For a parameter to be passed correctly to payment API, the string must be URI escaped according to the following rules:

All parameter names and values are escaped using the [RFC3986] percent-encoding (%xx) mechanism. Characters not in the unreserved character set ([RFC3986] section 2.3) MUST be encoded. Characters in the unreserved character set MUST NOT be encoded. Hexadecimal characters in encodings MUST be upper case. Text names and values MUST be encoded as UTF-8 octets before percent-encoding them per [RFC3629].

unreserved = ALPHA, DIGIT, '-', '.', '_', '~'

I am really confused looking at this page. I intend to do this in Javascript/jQuery. Is there a simple way or function to achieve this ? Please suggest if there is some external library that can do this if jQuery directly can not.

Regards

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Nikhil Khullar
  • 703
  • 6
  • 21
  • Welcome to Stack Overflow. The site policy discourages (for good reasons) questions and answers that are nothing but a link to an external site... and you even encoded the link as code so it wasn't clickable. I've edited the question and fixed these issues. – Álvaro González Dec 16 '13 at 11:51

1 Answers1

0

If you are looking for UTF-8 encodeing, you can use encodeURIComponent():

var encodedURI = encodeURIComponent(str);

Hariprasad
  • 3,556
  • 2
  • 24
  • 40