如何在JavaScript中将特殊符号转换为表情符号字符?

时间:2019-06-26 07:36:45

标签: javascript

我需要将特殊字符转换为表情符号。

let text = "This time also delivered a big product in an awesome package and fast delivery, and one more thing, this product manufactured on May 19, onlyðððð totally 5¶¶¶¶¶ starts, to this product but front is made up of some type of steel but it is not up to me, remaining is really good";

2 个答案:

答案 0 :(得分:0)

如果要在文本中添加表情符号,则可以直接将其添加到字符串中:

https://www.kirupa.com/html5/emoji.htm

另一方面,如果文本是输入内容,并且您希望提取表情符号,则可以使用以下程序包:

https://github.com/iamcal/js-emoji

答案 1 :(得分:0)

ES6 / ES2015通过将代码包装在图形括号中,引入了一种在星体平面中表示Unicode点的方法(任何需要超过4个字符的Unicode代码点):

格式: \u{XXXXX}

例如:

\u{1F436}将起作用,并出现狗表情符号

作为参考,您可以签出this link