Last active
November 16, 2015 23:03
-
-
Save A1rPun/20f1649b7c3f9c69716a to your computer and use it in GitHub Desktop.
Encode/Decode XML meta characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function htmlDecode(s) { | |
var el = document.createElement("div"); | |
el.innerHTML = s; | |
return el.textContent; | |
} | |
function htmlEncode(s) { | |
var el = document.createElement("div"); | |
el.textContent = s; | |
return el.innerHTML; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment