Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

How to prevent Unicode characters from rendering as emoji in HTML from JavaScript?

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 ⚠). These are preferable, since I can apply CSS styles (such as color) to them.

image of warning glyph

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

image of hourglass emoji

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?

Update: It seems (from comments below) there is a text presentation selector, FE0E, available to enforce text-vs-emoji. The selector is concatenated as a suffix without space onto the character's code, such as ⌛︎ for HTML hex or u231BuFE0E for JS. However, it is simply not honored by all browsers (eg Chrome and Edge).

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Append the Unicode variation selector character for forcing text, VS15, ︎.
This forces the previous character to be rendered as text rather than as an Emoji Symbol.

<p>??&#xFE0E;</p>

Result: ??︎

Learn more at: Unicode symbol as text or emoji


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...