URL Decode

C

cc96ai

I got a String — how could I decode back into HTML which is
using Javascript ?

I try to use unescape , but no luck on it .
 
D

David Mark

I got a String — how could I decode back into HTML which is
using Javascript ?

I try to use unescape , but no luck on it .

Luck has nothing to do with it. It isn't escaped. Create a text node
with it and then use its nodeValue.
 
B

Bart Van der Donck

cc96ai said:
I got a String — how could I decode back into
HTML which is using Javascript ?
I try to use unescape , but no luck on it .

— is not a URL-encoding, but a HTML character entity reference.
The javascript 'unescape' command only works with URL-encoding
(=precent-encoding). Sorry for the nitpick, but it's important to use
the right terminology here, see:

http://en.wikipedia.org/wiki/Numeric_character_reference
http://en.wikipedia.org/wiki/Character_entity_reference
http://en.wikipedia.org/wiki/Percent-encoding

Code point 8212 may be represented by:

URL-encoding (UTF-8) = %E2%80%94
URL-encoding (ASCII) = [not encoded]
Character entity reference = —
Numeric entity reference = —

I think you're looking for something like this:

http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/42c7552d181f93fe/
 
D

David Mark

And then what? It's nodeValue will give you a literal representation.

I should have worded that more specifically. Create a text node and
add it to a DOM element. Then I presume can retrieve the expanded
entity with nodeValue. I know you can do this with innerHTML and this
would seem the standard equivalent to me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,417
Latest member
DarrenGaun

Latest Threads

Top