如何防止Unicode字符呈现为HTML中的表情符号从JavaScript? [英] How to prevent Unicode characters from rendering as emoji in HTML from JavaScript?

查看:282
本文介绍了如何防止Unicode字符呈现为HTML中的表情符号从JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在



其他正在渲染为较新的卡通表情符号,如⌛(沙漏, \\\⌛ ⌛ )。这些不是优选的,因为我不能完全风格他们。





看起来浏览器正在进行此更改,因为我能够在Mac Firefox上查看沙漏字形,只是没有Mac Chrome或Mac Safari。



有没有办法强制浏览器显示较旧的(平面单色)版本?



示例: http://jsbin.com / dihoqa / edit?html,js,console,output



更新:看起来后缀( FE0E )强制执行文本对表情符号。将后缀连接到字符的代码,例如⌛&#xFE0E (对于HTML hex或 \\\⌛\ uFE0E for JS。

解决方案

我收到了这封电子邮件一种防止这种情况的方法。在字符后面附加这段代码︎ ,强制将其定义为TEXT而不是表情符号。

 < p>

I'm finding Unicode for special characters from FileFormat.Info's search.

Some characters are rendering as the classic black-and-white glyphs, such as ⚠ (warning sign, \u26A0 or &#x26a0;). These are preferable, since I can apply CSS styles (such as color) to them.

Others are rendering as newer cartoony emoji, such as ⌛ (hourglass, \u231B or &#x231b;). These are not preferable, since I cannot fully style them.

It appears that the browser is making this change, since I'm able to see the hourglass glyph on Mac Firefox, just not Mac Chrome nor Mac Safari.

Is there a way to force browsers to display the older (flat monotone) versions to display?

Examples: http://jsbin.com/dihoqa/edit?html,js,console,output

Update: It seems (from comments below) there is a suffix available (FE0E) to enforce text-vs-emoji. The suffix is concatenated without space onto the character's code, such as &#x231b;&#xFE0E for HTML hex or \u231B\uFE0E for JS. However, it is simply not honored by all browsers (namely Mac Chrome).

解决方案

I Got a way to prevent this case. Just append this piece of code &#xFE0E; after the character, to force define it as TEXT rather than Emoji Symbol.

<p>
                        

这篇关于如何防止Unicode字符呈现为HTML中的表情符号从JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆