# Javascript unescape

**URL:** <https://www.ruby-forum.com/t/javascript-unescape/142084>\
**Category:** Rails\
**Created:** [July 3, 2008, 10:25am UTC](https://www.ruby-forum.com/t/javascript-unescape/142084 "2008-07-03T10:25:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sazwqa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ea5d25/32.png) [@sazwqa](https://www.ruby-forum.com/u/sazwqa)\
**Post date:** [July 3, 2008, 10:25am UTC](https://www.ruby-forum.com/t/javascript-unescape/142084/1 "2008-07-03T10:25:06Z")

</div>

In one of my applications I use the results from google ajax api  
(which outputs JSON) and I’m getting an unescaped string like this:

“Sam\u0026#39;s Home Page”

which is basically :

“Sam’s Home Page”

what is happening here is like this (my guess from observation):

’ (apostrophe) is escaped by HTML first so it becomes =\> ’  
’ is escaped by javascript and it becomes \u0026#39;

Though I can unescape the text on client side (using javascript  
unescape method) but I do need some implementation like this on the  
server also.

I have googled a lot and found that there is no equivalent of  
javascript escape and unescape for any language since they are  
dependent on current character encoding of HTML page.

Further I have tried the CGI.unescapeHTML and CGI.unescape methods  
also, that too din’t helped.

any help ?
