Created
July 19, 2022 10:28
-
-
Save breenie/04fa20ac13bd4c8c58fdbfb88577c414 to your computer and use it in GitHub Desktop.
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
// Thanks go to some random, but forgotten, SE page. | |
const sane = JSON.stringify("Emdashses should be banned. –") | |
.replace( | |
/[^\x20-\x7F]/g, | |
x => "\\u" + ("000" + x.codePointAt(0).toString(16)).slice(-4) | |
); | |
console.log(sane); | |
// Emdashses should be banned. \u2013 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment