Created
March 10, 2023 09:48
-
-
Save vwrs/2d3e24638fcf664a88061a82ac3721f4 to your computer and use it in GitHub Desktop.
convert unicode characters to string
This file contains 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
// ref: https://stackoverflow.com/questions/17267329/converting-unicode-character-to-string-format | |
function unicodeToChar(text) { | |
return text.replace(/\\u[\dA-F]{4}/gi, | |
function (match) { | |
return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment