Skip to content

Instantly share code, notes, and snippets.

View chen86860's full-sized avatar
👀
Hacking

Jack chen86860

👀
Hacking
  • Hangzhou,China
View GitHub Profile
@chen86860
chen86860 / str-to-unicode.js
Last active December 5, 2023 03:32
JavaScript String To Unicode/Unicode To String
/**
* string to unicode
*/
const strToUnicode = (str) => {
return Array.from(str)
.map((char) => {
const codePoint = char.codePointAt(0);
// For code points less than 0xFFFF, use `padStart` to ensure that
// the code point is at least four characters in length, and pad with zeros at the front.