Created
September 16, 2019 08:06
-
-
Save codebubb/4e325b6d7ea1b868b0fa8f6ca3ef1e48 to your computer and use it in GitHub Desktop.
Encode HTML Entities with JavaScript
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 encodeHTML = str => str.replace(/[\u00A0-\u9999<>\&]/gim, (i) => `&#${i.charCodeAt(0)};`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment