How to convert one emoji character to Unicode codepoint number in JavaScript?

前端 未结 5 665
囚心锁ツ
囚心锁ツ 2020-12-03 15:25

how to convert this

5条回答
  •  萌比男神i
    2020-12-03 16:07

    This is what I use:

    const toUni = function (str) {
      if (str.length < 4)
        return str.codePointAt(0).toString(16);
      return str.codePointAt(0).toString(16) + '-' + str.codePointAt(2).toString(16);
    };
    

提交回复
热议问题