简体   繁体   English

如何获得一些代码点表情符号值

[英]How to get some of the codepoint emoji values to work

在此处输入图片说明 For example: "rolling on the floor laughing" gives a square in the browser. 例如:“在地上滚动笑”在浏览器中给出一个正方形。 How do I get the actual emoji to show up not like a suqare? 如何获得不像suqare那样显示的实际表情符号?

String.fromCodePoint(0x1F923)

Here is a pic of arups jsbin that shows up like this: 这是arups jsbin的图片,显示如下: 在此处输入图片说明

This example is working for me on Firefox 61. The output is: 本示例在Firefox 61上为我工作。输出为:

在此处输入图片说明

And on Google Chrome I'm having: 在Google Chrome上,我拥有:

在此处输入图片说明

Now, try running this code snippet: 现在,尝试运行以下代码片段:

 document.querySelector('.output').textContent = String.fromCodePoint(0x1F923); console.log(String.fromCodePoint(0x1F923)); 
 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Bin</title> </head> <body> <p class='output'></p> </body> </html> 

If you still getting that square, please check your browser's encoding & your default fonts. 如果仍能找到该正方形,请检查浏览器的编码和默认字体。 And check if it supports emojis, like on my Google Chrome didn't render it. 并检查它是否支持表情符号,例如在我的Google Chrome浏览器上未呈现它。

So maybe you need to use a third-party JavaScript library like Twitter's Twemoji : 因此,也许您需要使用Twitter的Twemoji之类的第三方JavaScript库:

 // I got the Unicode for that emoji(1F602) from www.unicode.org/emoji/charts/full-emoji-list.html document.querySelector('.output').innerHTML = twemoji.convert.fromCodePoint('1F602'); 
 <script src="//twemoji.maxcdn.com/2/twemoji.min.js?11.0"></script> <p class="output"></p> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM