string - How to compose emoji unicode dynamically from "1f628" to "u{1f628}" with javascript

I'm trying to convert a unified string of emoji.Getting error when trying to do this:var code = &#

I'm trying to convert a unified string of emoji.

Getting error when trying to do this:

var code = '1f628'
`\u{${code}}`

SyntaxError: Invalid Unicode escape sequence

How can I make it work?

I'm trying to convert a unified string of emoji.

Getting error when trying to do this:

var code = '1f628'
`\u{${code}}`

SyntaxError: Invalid Unicode escape sequence

How can I make it work?

Share edited Mar 12, 2018 at 12:41 F0XS 1,2693 gold badges16 silver badges19 bronze badges asked Mar 12, 2018 at 12:28 Ilya LibinIlya Libin 1,6272 gold badges19 silver badges40 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

String.fromCodePoint will get you the character from its numeric code point, and parseInt will get you the number from a hex string:

var code = '1f628';
String.fromCodePoint(parseInt(code, 16)); // 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744912773a4600653.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信