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 badges1 Answer
Reset to default 10String.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条)