http://www.youtube.com/watch?feature=endscreen&NR=1&v=Ahha3Cqe_fk
For some reason, the string is that. How can I change the &
and make them real symbols?
Do I URL encode or decode?
http://www.youtube.com/watch?feature=endscreen&NR=1&v=Ahha3Cqe_fk
For some reason, the string is that. How can I change the &
and make them real symbols?
Do I URL encode or decode?
$("<div>", {html: "http://www.youtube.com/watch?feature=endscreen&NR=1&v=Ahha3Cqe_fk"}).text()
or
var div = document.createElement("div");
div.innerHTML = "http://www.youtube.com/watch?feature=endscreen&NR=1&v=Ahha3Cqe_fk";
div.firstChild.nodeValue;
$url=str_replace("&","&",$url);
It has nothing to do with url encoding. & is an HTML entity of the & symbol.
Pretty much the same deal in JS
url.replace("&","&");
Create a DOM element, assign above encoded string to its innerHTML
and return nodeValue
.
That will be a more robust solution. If you simply want to tackle this one entity an explicit .replace()
will do the trick: url.replace(/&/g, "&")
.