Created
September 18, 2022 01:39
-
-
Save nicholasadamou/4c104c6c4552322062e18690db819877 to your computer and use it in GitHub Desktop.
Convert HTML to HTML Entities
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
const toHTMLEntities = (html) => { | |
let result = ''; | |
for (let i = 0; i < html.length; i++) { | |
result += "&#x" + html[i].charCodeAt(0).toString(16) + ";"; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment