← 所有文章

JavaScript String 转到 UTF-16 编码

· · 原 issue #3 ↗
function tounicode(s) {
  return s.charCodeAt().toString(16)
}

在JavaScript中,字符串可以表示为 '\u{${tounicode(s)}}' 的格式 ,实际作用可以用正则来匹配一些预定义的特殊字符,比如 $, + 之类的

作为备忘

评论

评论加载中;也可通过上方原 issue 链接查看讨论。